Haehnchen / idea-php-phpunit-plugin

IntelliJ IDEA / PhpStorm PHPUnit Enhancement Plugin
MIT License
55 stars 11 forks source link

Prophecy support for inherited classes #24

Open astehlik opened 6 years ago

astehlik commented 6 years ago

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();
    }
}
kobelobster commented 6 years ago

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

Haehnchen commented 6 years ago

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