Consider the following test case:
class FooTest extends \PHPUnit_Framework_TestCase
{
public $foo;
public function setUp()
{
$this->foo = new Foo();
}
public function testBar()
{
$expected = 42;
$actual = $this->foo->bar();
$this->assertEqual($expected, $actual);
}
Because $this->foo
is instantiated in setUp
PhpStorm doesn't recognize it as an instance of Foo
in the subsequent test methods. As a result a lot of the IDE power is lost (loosing completion lookups and such). PhpStorm even complains that bar
isn't a method of $this->foo
even though it is.
Is there an effective way of getting PhpStorm to recognize instances defined in setUp
; much like it would if they were defined in __construct
? Maybe there's a whole suite of PhpStorm functionality I'm missing? Or just a hacky work around?