class PluginBaseTest

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

@coversDefaultClass \Drupal\Component\Plugin\PluginBase @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 13

Namespace

Drupal\Tests\Component\Plugin
View source
class PluginBaseTest extends TestCase {
    
    /**
     * @dataProvider providerTestGetPluginId
     * @covers ::getPluginId
     */
    public function testGetPluginId($plugin_id, $expected) : void {
        $plugin_base = $this->getMockForAbstractClass('Drupal\\Component\\Plugin\\PluginBase', [
            [],
            $plugin_id,
            [],
        ]);
        $this->assertEquals($expected, $plugin_base->getPluginId());
    }
    
    /**
     * Returns test data for testGetPluginId().
     *
     * @return array
     */
    public static function providerTestGetPluginId() {
        return [
            [
                'base_id',
                'base_id',
            ],
            [
                'base_id:derivative',
                'base_id:derivative',
            ],
        ];
    }
    
    /**
     * @dataProvider providerTestGetBaseId
     * @coves ::getBaseId
     */
    public function testGetBaseId($plugin_id, $expected) : void {
        
        /** @var \Drupal\Component\Plugin\PluginBase|\PHPUnit\Framework\MockObject\MockObject $plugin_base */
        $plugin_base = $this->getMockForAbstractClass('Drupal\\Component\\Plugin\\PluginBase', [
            [],
            $plugin_id,
            [],
        ]);
        $this->assertEquals($expected, $plugin_base->getBaseId());
    }
    
    /**
     * Returns test data for testGetBaseId().
     *
     * @return array
     */
    public static function providerTestGetBaseId() {
        return [
            [
                'base_id',
                'base_id',
            ],
            [
                'base_id:derivative',
                'base_id',
            ],
        ];
    }
    
    /**
     * @dataProvider providerTestGetDerivativeId
     * @covers ::getDerivativeId
     */
    public function testGetDerivativeId($plugin_id = NULL, $expected = NULL) : void {
        
        /** @var \Drupal\Component\Plugin\PluginBase|\PHPUnit\Framework\MockObject\MockObject $plugin_base */
        $plugin_base = $this->getMockForAbstractClass('Drupal\\Component\\Plugin\\PluginBase', [
            [],
            $plugin_id,
            [],
        ]);
        $this->assertEquals($expected, $plugin_base->getDerivativeId());
    }
    
    /**
     * Returns test data for testGetDerivativeId().
     *
     * @return array
     */
    public static function providerTestGetDerivativeId() {
        return [
            [
                'base_id',
                NULL,
            ],
            [
                'base_id:derivative',
                'derivative',
            ],
        ];
    }
    
    /**
     * @covers ::getPluginDefinition
     */
    public function testGetPluginDefinition() : void {
        $plugin_base = $this->getMockForAbstractClass('Drupal\\Component\\Plugin\\PluginBase', [
            [],
            '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 @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

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