idea-php-phpunit-plugin icon indicating copy to clipboard operation
idea-php-phpunit-plugin copied to clipboard

Prophecy support for inherited classes

Open astehlik opened this issue 7 years ago • 2 comments

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();
    }
}

astehlik avatar Aug 17 '17 08:08 astehlik

+1 Just wanted to open the same issue, this feature would be awesome. @Haehnchen any plans?

kobelobster avatar Sep 26 '17 07:09 kobelobster

indeed good idea, possible but not that easy to implement, will think about it

Haehnchen avatar Oct 03 '17 12:10 Haehnchen