maxfilatov / phpuaca

PHPUnit Autocomplete Assistant (PhpStorm plugin)
50 stars 24 forks source link

Enabled method completion with mock class as string parameter #3

Closed King2500 closed 8 years ago

King2500 commented 9 years ago

This pull-request allows method completion when mocked class is parametrized as string instead of a class constant:

// MockBuilderFilter

$this->getMockBuilder('\ThomasSchulz\ClockUtil\Clock')
    ->setMethods(array('<caret>'));

$this->getMock('\ThomasSchulz\ClockUtil\Clock', array('<caret>'));
$this->getMockClass('\ThomasSchulz\ClockUtil\Clock', array('<caret>'));
$this->getMockForAbstractClass('\ThomasSchulz\ClockUtil\Clock', 
    array(), '', true, true, true, array('<caret>'));
$this->getMockForTrait('\ThomasSchulz\ClockUtil\Clock', 
    array(), '', true, true, true, array('<caret>'));

// InvocationMockerFilter

$mock = $this->getMockBuilder('\ThomasSchulz\ClockUtil\Clock')
    ->setMethods(array('test1', 'test2'))
    ->getMock();
$mock->expects($this->once())->method('<caret>');

It also works with double-quote strings:

$this->getMock("\\ThomasSchulz\\ClockUtil\\Clock", array('<caret>'));
maxfilatov commented 8 years ago

Hi Thomas

There is some refactoring of your realisation here: https://github.com/maxfilatov/phpuaca/commit/5992c731543a34efb70c73e956ee13787f561892?diff=unified

  1. Methods getPhpClass/setPhpClass instead of getClassConstantReference/setClassConstantReference/getClassName/setClassName in filters
  2. PhpClass is resolved in ClassFinder
King2500 commented 8 years ago

Fine.

Whats left to do here?

maxfilatov commented 8 years ago

Nothing. So, these changes will be in master in next 2 weeks after tests