You are here

class PluginBaseTest in Zircon Profile 8

Same name in this branch
  1. 8 core/tests/Drupal/Tests/Component/Plugin/PluginBaseTest.php \Drupal\Tests\Component\Plugin\PluginBaseTest
  2. 8 core/modules/views/tests/src/Unit/PluginBaseTest.php \Drupal\Tests\views\Unit\PluginBaseTest
  3. 8 core/modules/views/src/Tests/Plugin/PluginBaseTest.php \Drupal\views\Tests\Plugin\PluginBaseTest
Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Component/Plugin/PluginBaseTest.php \Drupal\Tests\Component\Plugin\PluginBaseTest

@coversDefaultClass \Drupal\Component\Plugin\PluginBase @group Plugin

Hierarchy

  • class \Drupal\Tests\UnitTestCase extends \Drupal\Tests\PHPUnit_Framework_TestCase

Expanded class hierarchy of PluginBaseTest

File

core/tests/Drupal/Tests/Component/Plugin/PluginBaseTest.php, line 16
Contains \Drupal\Tests\Component\Plugin\PluginBaseTest.

Namespace

Drupal\Tests\Component\Plugin
View source
class PluginBaseTest extends UnitTestCase {

  /**
   * @dataProvider providerTestGetPluginId
   * @covers ::getPluginId
   */
  public function testGetPluginId($plugin_id, $expected) {
    $plugin_base = $this
      ->getMockForAbstractClass('Drupal\\Component\\Plugin\\PluginBase', array(
      array(),
      $plugin_id,
      array(),
    ));
    $this
      ->assertEquals($expected, $plugin_base
      ->getPluginId());
  }

  /**
   * Returns test data for testGetPluginId().
   *
   * @return array
   */
  public function providerTestGetPluginId() {
    return array(
      array(
        'base_id',
        'base_id',
      ),
      array(
        'base_id:derivative',
        'base_id:derivative',
      ),
    );
  }

  /**
   * @dataProvider providerTestGetBaseId
   * @coves ::getBaseId
   */
  public function testGetBaseId($plugin_id, $expected) {

    /** @var \Drupal\Component\Plugin\PluginBase|\PHPUnit_Framework_MockObject_MockObject $plugin_base */
    $plugin_base = $this
      ->getMockForAbstractClass('Drupal\\Component\\Plugin\\PluginBase', array(
      array(),
      $plugin_id,
      array(),
    ));
    $this
      ->assertEquals($expected, $plugin_base
      ->getBaseId());
  }

  /**
   * Returns test data for testGetBaseId().
   *
   * @return array
   */
  public function providerTestGetBaseId() {
    return array(
      array(
        'base_id',
        'base_id',
      ),
      array(
        'base_id:derivative',
        'base_id',
      ),
    );
  }

  /**
   * @dataProvider providerTestGetDerivativeId
   * @covers ::getDerivativeId
   */
  public function testGetDerivativeId($plugin_id = NULL, $expected = NULL) {

    /** @var \Drupal\Component\Plugin\PluginBase|\PHPUnit_Framework_MockObject_MockObject $plugin_base */
    $plugin_base = $this
      ->getMockForAbstractClass('Drupal\\Component\\Plugin\\PluginBase', array(
      array(),
      $plugin_id,
      array(),
    ));
    $this
      ->assertEquals($expected, $plugin_base
      ->getDerivativeId());
  }

  /**
   * Returns test data for testGetDerivativeId().
   *
   * @return array
   */
  public function providerTestGetDerivativeId() {
    return array(
      array(
        'base_id',
        NULL,
      ),
      array(
        'base_id:derivative',
        'derivative',
      ),
    );
  }

  /**
   * @covers ::getPluginDefinition
   */
  public function testGetPluginDefinition() {
    $plugin_base = $this
      ->getMockForAbstractClass('Drupal\\Component\\Plugin\\PluginBase', array(
      array(),
      'plugin_id',
      array(
        'value',
        array(
          'key' => 'value',
        ),
      ),
    ));
    $this
      ->assertEquals(array(
      'value',
      array(
        'key' => 'value',
      ),
    ), $plugin_base
      ->getPluginDefinition());
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PluginBaseTest::providerTestGetBaseId public function Returns test data for testGetBaseId().
PluginBaseTest::providerTestGetDerivativeId public function Returns test data for testGetDerivativeId().
PluginBaseTest::providerTestGetPluginId public function Returns test data for testGetPluginId().
PluginBaseTest::testGetBaseId public function @dataProvider providerTestGetBaseId @coves ::getBaseId
PluginBaseTest::testGetDerivativeId public function @dataProvider providerTestGetDerivativeId @covers ::getDerivativeId
PluginBaseTest::testGetPluginDefinition public function @covers ::getPluginDefinition
PluginBaseTest::testGetPluginId public function @dataProvider providerTestGetPluginId @covers ::getPluginId
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root.
UnitTestCase::assertArrayEquals protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getBlockMockWithMachineName protected function Mocks a block with a block plugin.
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed in 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.
UnitTestCase::setUp protected function 259