You are here

abstract class PluginSelectorBaseTestBase in Plugin 8.2

Provides a base for tests for classes that extend \Drupal\plugin\Plugin\Plugin\PluginSelector\PluginSelectorBase.

Hierarchy

Expanded class hierarchy of PluginSelectorBaseTestBase

File

tests/src/Unit/Plugin/Plugin/PluginSelector/PluginSelectorBaseTestBase.php, line 15

Namespace

Drupal\Tests\plugin\Unit\Plugin\Plugin\PluginSelector
View source
abstract class PluginSelectorBaseTestBase extends UnitTestCase {

  /**
   * The default plugin resolver.
   *
   * @var \Drupal\plugin\DefaultPluginResolver\DefaultPluginResolverInterface|\PHPUnit_Framework_MockObject_MockObject
   */
  protected $defaultPluginResolver;

  /**
   * The plugin definition of the class under test.
   *
   * @var array
   */
  protected $pluginDefinition = [];

  /**
   * The plugin ID of the class plugin under test.
   *
   * @var array
   */
  protected $pluginId;

  /**
   * The plugin manager through which to select plugins.
   *
   * @var \Drupal\Component\Plugin\PluginManagerInterface|\PHPUnit_Framework_MockObject_MockObject
   */
  protected $selectablePluginManager;

  /**
   * The plugin type of which to select plugins.
   *
   * @var \Drupal\plugin\PluginType\PluginTypeInterface|\PHPUnit_Framework_MockObject_MockObject
   */
  protected $selectablePluginType;

  /**
   * The selected plugin.
   *
   * @var \Drupal\Component\Plugin\PluginInspectionInterface|\PHPUnit_Framework_MockObject_MockObject
   */
  protected $selectedPlugin;

  /**
   * The class under test.
   *
   * @var \Drupal\plugin\Plugin\Plugin\PluginSelector\PluginSelectorBase|\PHPUnit_Framework_MockObject_MockObject
   */
  protected $sut;

  /**
   * {@inheritdoc}
   *
   */
  protected function setUp() : void {
    $this->defaultPluginResolver = $this
      ->createMock(DefaultPluginResolverInterface::class);
    $this->pluginId = $this
      ->randomMachineName();
    $this->selectablePluginManager = $this
      ->createMock(PluginManagerInterface::class);
    $this->selectablePluginType = $this
      ->createMock(PluginTypeInterface::class);
    $this->selectablePluginType
      ->expects($this
      ->any())
      ->method('getPluginManager')
      ->willReturn($this->selectablePluginManager);
    $this->selectedPlugin = $this
      ->createMock(PluginInspectionInterface::class);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PhpunitCompatibilityTrait::getMock Deprecated public function Returns a mock object for the specified class using the available method.
PhpunitCompatibilityTrait::setExpectedException Deprecated public function Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
PluginSelectorBaseTestBase::$defaultPluginResolver protected property The default plugin resolver.
PluginSelectorBaseTestBase::$pluginDefinition protected property The plugin definition of the class under test.
PluginSelectorBaseTestBase::$pluginId protected property The plugin ID of the class plugin under test.
PluginSelectorBaseTestBase::$selectablePluginManager protected property The plugin manager through which to select plugins.
PluginSelectorBaseTestBase::$selectablePluginType protected property The plugin type of which to select plugins.
PluginSelectorBaseTestBase::$selectedPlugin protected property The selected plugin.
PluginSelectorBaseTestBase::$sut protected property The class under test. 4
PluginSelectorBaseTestBase::setUp protected function Overrides UnitTestCase::setUp 4
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root. 1
UnitTestCase::assertArrayEquals protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getBlockMockWithMachineName Deprecated protected function Mocks a block with a block plugin. 1
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.