Skip to content

Prophecy support for inherited classes #24

Open
@astehlik

Description

@astehlik

It would be great if prophecies are recognized, that are defined in a parent class (e.g. in the setUp() method).

For example:

class TheParentTest extends \PHPUnit\Framework\TestCase
{
    /**
     * @var \Prophecy\Prophecy\ObjectProphecy|TheProphesizedClass
     */
    protected $myProphecy;

    public function setUp()
    {
        $this->myProphecy = $this->prophesize(TheProphesizedClass::class);
    }

    /**
     * @test
     */
    public function someTest()
    {
        // This works fine
        $this->myProphecy->someMethod()->shouldBeCalled();
    }
}

class TheTest extends TheParentTest
{
    /**
     * @test
     */
    public function someTest()
    {
        // This causes an IDE warning.
        $this->myProphecy->someMethod()->shouldBeCalled();
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions