Mercurial > hg > cmmr2012-drupal-site
comparison core/tests/Drupal/Tests/Component/Annotation/PluginIdTest.php @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c75dbcec494b |
---|---|
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 } |