Version 1
[yaffs-website] / web / modules / contrib / linkit / src / Tests / Controllers / LinkitControllerTest.php
1 <?php
2
3 /**
4  * @file
5  * Contains \Drupal\linkit\Tests\Controllers\LinkitControllerTest.
6  */
7
8 namespace Drupal\linkit\Tests\Controllers;
9
10 use Drupal\Core\Url;
11 use Drupal\linkit\Tests\LinkitTestBase;
12
13
14 /**
15  * Tests Linkit controller.
16  *
17  * @group linkit
18  */
19 class LinkitControllerTest extends LinkitTestBase {
20
21   /**
22    * The linkit profile.
23    *
24    * @var \Drupal\linkit\ProfileInterface
25    */
26   protected $linkitProfile;
27
28   /**
29    * {@inheritdoc}
30    */
31   protected function setUp() {
32     parent::setUp();
33
34     $this->linkitProfile = $this->createProfile();
35
36     $this->drupalLogin($this->adminUser);
37   }
38
39   /**
40    * Tests the profile route title callback.
41    */
42   function testProfileTitle() {
43     $this->drupalGet(Url::fromRoute('entity.linkit_profile.edit_form', [
44       'linkit_profile' => $this->linkitProfile->id(),
45     ]));
46
47     $this->assertText('Edit ' . $this->linkitProfile->label() . ' profile');
48   }
49
50   /**
51    * Tests the matcher route title callback.
52    */
53   function testMatcherTitle() {
54     /** @var \Drupal\linkit\MatcherInterface $plugin */
55     $plugin = $this->container->get('plugin.manager.linkit.matcher')->createInstance('configurable_dummy_matcher');
56     $matcher_uuid = $this->linkitProfile->addMatcher($plugin->getConfiguration());
57     $this->linkitProfile->save();
58
59     $this->drupalGet(Url::fromRoute('linkit.matcher.edit', [
60       'linkit_profile' => $this->linkitProfile->id(),
61       'plugin_instance_id' => $matcher_uuid,
62     ]));
63
64     $this->assertText('Edit ' . $plugin->getLabel() . ' matcher');
65   }
66
67   /**
68    * Tests the attribute route title callback.
69    */
70   function testAttributeTitle() {
71     /** @var \Drupal\linkit\AttributeInterface $plugin */
72     $plugin = $this->container->get('plugin.manager.linkit.attribute')->createInstance('configurable_dummy_attribute');
73     $this->linkitProfile->addAttribute($plugin->getConfiguration());
74     $this->linkitProfile->save();
75
76     $this->drupalGet(Url::fromRoute('linkit.attribute.edit', [
77       'linkit_profile' => $this->linkitProfile->id(),
78       'plugin_instance_id' => $plugin->getPluginId(),
79     ]));
80     $this->assertText('Edit ' . $plugin->getLabel() . ' attribute');
81   }
82
83 }