Haehnchen/idea-php-phpunit-plugin

No autocomplete for test class field

overgapo opened this issue · 7 comments

class A {
    public function foo() {}
}

class FooTest extends \PHPUnit_Framework_TestCase
{
    /** @var A|ObjectProphecy */
    private $a;

    protected function setUp(): void
    {
        $this->a = $this->prophesize(A::class);
    }

    public function testFoo(): void
    {
        // $this->a->foo()-> no autocomplete

        $a = $this->prophesize(A::class);
        $a->foo()->shouldBeCalledTimes(1); // /ok
    }
}

Just for info I have the same.

@overgapo, @jonnywilliamson: This works for me on the latest version (v2.2.1).

@Hipio, try to get autocomplete for ->shouldBeCalledTimes(1) method after $this->example->bar()

@overgapo You are correct, it does indeed not work, I retract my statement. It gives me two warning messages:

  • 'void' method 'bar' result used
  • Method 'shouldBeCalledTimes' not found in void
scheb commented

Any update on this? I'm using plugin version 2.7 on PhpStorm 2017.2.4 and I have the same behavior that @overgapo showed above. Sadly this makes Prophecy quite hard to use when you want to create the unit-under-test and the mocks in the setUp method.

Any update on this issue?
I have got the same problem.
I am storing mock to class property in setUp method like this

image

tested and working