More updates to stop using dev or alpha or beta versions.
[yaffs-website] / web / core / tests / Drupal / Tests / Component / Annotation / PluginIdTest.php
1 <?php
2
3 namespace Drupal\Tests\Component\Annotation;
4
5 use Drupal\Component\Annotation\PluginID;
6 use PHPUnit\Framework\TestCase;
7
8 /**
9  * @coversDefaultClass \Drupal\Component\Annotation\PluginId
10  * @group Annotation
11  */
12 class PluginIdTest extends TestCase {
13
14   /**
15    * @covers ::get
16    */
17   public function testGet() {
18     // Assert plugin starts empty regardless of constructor.
19     $plugin = new PluginID([
20       'foo' => 'bar',
21       'biz' => [
22         'baz' => 'boom',
23       ],
24       'nestedAnnotation' => new PluginID([
25         'foo' => 'bar',
26       ]),
27       'value' => 'biz',
28     ]);
29     $this->assertEquals([
30       'id' => NULL,
31       'class' => NULL,
32       'provider' => NULL,
33     ], $plugin->get());
34
35     // Set values and ensure we can retrieve them.
36     $plugin->value = 'foo';
37     $plugin->setClass('bar');
38     $plugin->setProvider('baz');
39     $this->assertEquals([
40       'id' => 'foo',
41       'class' => 'bar',
42       'provider' => 'baz',
43     ], $plugin->get());
44   }
45
46   /**
47    * @covers ::getId
48    */
49   public function testGetId() {
50     $plugin = new PluginID([]);
51     $plugin->value = 'example';
52     $this->assertEquals('example', $plugin->getId());
53   }
54
55 }