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