PluginTest.php

Same filename in this branch
  1. 11.x core/tests/Drupal/Tests/Component/Annotation/PluginTest.php
Same filename and directory in other branches
  1. 9 core/tests/Drupal/Tests/Component/Annotation/PluginTest.php
  2. 8.9.x core/tests/Drupal/Tests/Component/Annotation/PluginTest.php
  3. 10 core/tests/Drupal/Tests/Component/Annotation/PluginTest.php
  4. 10 core/tests/Drupal/Tests/Component/Plugin/Attribute/PluginTest.php

Namespace

Drupal\Tests\Component\Plugin\Attribute

File

core/tests/Drupal/Tests/Component/Plugin/Attribute/PluginTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\Component\Plugin\Attribute;

use Drupal\Component\Plugin\Attribute\Plugin;
use PHPUnit\Framework\TestCase;

/**
 * @coversDefaultClass \Drupal\Component\Plugin\Attribute\Plugin
 * @group Attribute
 */
class PluginTest extends TestCase {
    
    /**
     * @covers ::__construct
     * @covers ::get
     */
    public function testGet() : void {
        $plugin = new PluginStub(id: 'example', deriver: 'test');
        $plugin->setClass('foo');
        $this->assertEquals([
            'id' => 'example',
            'class' => 'foo',
            'deriver' => 'test',
        ], $plugin->get());
    }
    
    /**
     * @covers ::setProvider
     * @covers ::getProvider
     */
    public function testSetProvider() : void {
        $plugin = new Plugin(id: 'example');
        $plugin->setProvider('example');
        $this->assertEquals('example', $plugin->getProvider());
    }
    
    /**
     * @covers ::getId
     */
    public function testGetId() : void {
        $plugin = new Plugin(id: 'example');
        $this->assertEquals('example', $plugin->getId());
    }
    
    /**
     * @covers ::setClass
     * @covers ::getClass
     */
    public function testSetClass() : void {
        $plugin = new Plugin(id: 'test');
        $plugin->setClass('example');
        $this->assertEquals('example', $plugin->getClass());
    }

}

/**
 * {@inheritdoc}
 */
class PluginStub extends Plugin {

}

Classes

Title Deprecated Summary
PluginStub
PluginTest @coversDefaultClass \Drupal\Component\Plugin\Attribute\Plugin @group Attribute

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