PHPUnit Autocomplete Assistant

Compatible with: IntelliJ IDEA PhpStorm
26.07.2016
29 266

PhpStorm plugin to provide smart autocomplete, code navigation and refactoring features for mocked class methods.

Feature list

  • method autocomplete for class, abstract class and trait mock objects;

    • type providers: getMock, getMockForAbstractClass, etc. will return mock object with methods of mocking class and PHPUnit_Framework_MockObject_MockObject;
    • supported PHPUnit methods:

      PHPUnit_Framework_MockObject_MockBuilder::setMethods

      PHPUnit_Framework_TestCase::getMock

      PHPUnit_Framework_TestCase::getMockClass

      PHPUnit_Framework_TestCase::getMockForAbstractClass

      PHPUnit_Framework_TestCase::getMockForTrait

      PHPUnit_Framework_MockObject_Builder_InvocationMocker::method

  • code navigation (go to declaration, find usages, etc.) and refactoring (rename methods);
  • highlighting of incorrect method usages;
  • Prophecy support.

Examples

Mock creation

Mock usage

Download plugin

Recent change notes

1.3.5
  • Type providers for PHPUnit and Prophecy has been temporary removed for plugin stability reasons, will be fixed soon;
1.3.3
  • support for Prophecy property, argument and return type completion (by Steve Müller);
  • multiple fixes to prevent IDE freezes during updating indices process;
  • support for latest IDE versions (by Sebastian Hopfe);
1.3
  • code navigation (go to declaration, find usages, etc.) and refactoring (rename methods);
  • highlighting of incorrect method usages;
  • PHPUnit type provider;
  • Prophecy type provider;
  • legacy tests support: method completion for mocks defined by string class name instead of class constant reference, ::class (by Thomas Schulz).
1.2
  • Fixed false activation of plugin in classes with magic methods defined in PHPDoc blocks.
1.1
  • Added support for methods PHPUnit_Framework_TestCase::getMock, PHPUnit_Framework_TestCase::getMockClass, PHPUnit_Framework_TestCase::getMockForAbstractClass and PHPUnit_Framework_TestCase::getMockForTrait;
  • Already specified methods in mock definitions aren't used in next autocomplete suggestions;
  • Fixed multiple false activations of suggestion popup.
1.0
  • Added support for methods PHPUnit_Framework_MockObject_MockBuilder::setMethods and PHPUnit_Framework_MockObject_Builder_InvocationMocker::method.