class PluginBaseTest

Same name in this branch
  1. main core/modules/views/tests/src/Unit/PluginBaseTest.php \Drupal\Tests\views\Unit\PluginBaseTest
  2. main core/modules/views/tests/src/Kernel/Plugin/PluginBaseTest.php \Drupal\Tests\views\Kernel\Plugin\PluginBaseTest
Same name and namespace in other branches
  1. 11.x core/modules/views/tests/src/Unit/PluginBaseTest.php \Drupal\Tests\views\Unit\PluginBaseTest
  2. 11.x core/modules/views/tests/src/Kernel/Plugin/PluginBaseTest.php \Drupal\Tests\views\Kernel\Plugin\PluginBaseTest
  3. 11.x core/tests/Drupal/Tests/Component/Plugin/PluginBaseTest.php \Drupal\Tests\Component\Plugin\PluginBaseTest
  4. 10 core/modules/views/tests/src/Unit/PluginBaseTest.php \Drupal\Tests\views\Unit\PluginBaseTest
  5. 10 core/modules/views/tests/src/Kernel/Plugin/PluginBaseTest.php \Drupal\Tests\views\Kernel\Plugin\PluginBaseTest
  6. 10 core/tests/Drupal/Tests/Component/Plugin/PluginBaseTest.php \Drupal\Tests\Component\Plugin\PluginBaseTest
  7. 9 core/modules/views/tests/src/Unit/PluginBaseTest.php \Drupal\Tests\views\Unit\PluginBaseTest
  8. 9 core/modules/views/tests/src/Kernel/Plugin/PluginBaseTest.php \Drupal\Tests\views\Kernel\Plugin\PluginBaseTest
  9. 9 core/tests/Drupal/Tests/Component/Plugin/PluginBaseTest.php \Drupal\Tests\Component\Plugin\PluginBaseTest
  10. 8.9.x core/modules/views/tests/src/Unit/PluginBaseTest.php \Drupal\Tests\views\Unit\PluginBaseTest
  11. 8.9.x core/modules/views/tests/src/Kernel/Plugin/PluginBaseTest.php \Drupal\Tests\views\Kernel\Plugin\PluginBaseTest
  12. 8.9.x core/tests/Drupal/Tests/Component/Plugin/PluginBaseTest.php \Drupal\Tests\Component\Plugin\PluginBaseTest

Tests Drupal\Component\Plugin\PluginBase.

Attributes

#[CoversClass(PluginBase::class)] #[Group('Plugin')]

Hierarchy

  • class \Drupal\Tests\Component\Plugin\PluginBaseTest extends \PHPUnit\Framework\TestCase

Expanded class hierarchy of PluginBaseTest

File

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

Namespace

Drupal\Tests\Component\Plugin
View source
class PluginBaseTest extends TestCase {
  
  /**
   * Tests get plugin id.
   */
  public function testGetPluginId($plugin_id, $expected) : void {
    $plugin_base = new StubPluginBase([], $plugin_id, []);
    $this->assertEquals($expected, $plugin_base->getPluginId());
  }
  
  /**
   * Returns test data for testGetPluginId().
   *
   * @return array
   *   An array of test cases, where each item contains a plugin ID and
   *   the expected plugin ID result.
   */
  public static function providerTestGetPluginId() : array {
    return [
      [
        'base_id',
        'base_id',
      ],
      [
        'base_id:derivative',
        'base_id:derivative',
      ],
    ];
  }
  
  /**
   * Tests get base id.
   *
   * @coves ::getBaseId
   */
  public function testGetBaseId($plugin_id, $expected) : void {
    $plugin_base = new StubPluginBase([], $plugin_id, []);
    $this->assertEquals($expected, $plugin_base->getBaseId());
  }
  
  /**
   * Returns test data for testGetBaseId().
   *
   * @return array
   *   An array of test cases, where each item contains a plugin ID and
   *   the expected base ID result.
   */
  public static function providerTestGetBaseId() : array {
    return [
      [
        'base_id',
        'base_id',
      ],
      [
        'base_id:derivative',
        'base_id',
      ],
    ];
  }
  
  /**
   * Tests get derivative id.
   */
  public function testGetDerivativeId($plugin_id = NULL, $expected = NULL) : void {
    $plugin_base = new StubPluginBase([], $plugin_id, []);
    $this->assertEquals($expected, $plugin_base->getDerivativeId());
  }
  
  /**
   * Returns test data for testGetDerivativeId().
   *
   * @return array
   *   An array of test cases, where each item contains a plugin ID and
   *   the expected derivative ID result.
   */
  public static function providerTestGetDerivativeId() : array {
    return [
      [
        'base_id',
        NULL,
      ],
      [
        'base_id:derivative',
        'derivative',
      ],
    ];
  }
  
  /**
   * Tests get plugin definition.
   */
  public function testGetPluginDefinition() : void {
    $plugin_base = new StubPluginBase([], 'plugin_id', [
      'value',
      [
        'key' => 'value',
      ],
    ]);
    $this->assertEquals([
      'value',
      [
        'key' => 'value',
      ],
    ], $plugin_base->getPluginDefinition());
  }

}

Members

Title Sort descending Modifiers Object type Summary
PluginBaseTest::providerTestGetBaseId public static function Returns test data for testGetBaseId().
PluginBaseTest::providerTestGetDerivativeId public static function Returns test data for testGetDerivativeId().
PluginBaseTest::providerTestGetPluginId public static function Returns test data for testGetPluginId().
PluginBaseTest::testGetBaseId public function Tests get base id.
PluginBaseTest::testGetDerivativeId public function Tests get derivative id.
PluginBaseTest::testGetPluginDefinition public function Tests get plugin definition.
PluginBaseTest::testGetPluginId public function Tests get plugin id.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.