1db8bc5c6aa20bb61bcbb610289f0d695252f3c4
[yaffs-website] / web / core / modules / tour / src / Tests / TourTestBasic.php
1 <?php
2
3 namespace Drupal\tour\Tests;
4
5 /**
6  * Simple tour tips test base.
7  */
8 abstract class TourTestBasic extends TourTestBase {
9
10   /**
11    * Tour tip attributes to be tested. Keyed by the path.
12    *
13    * @var array
14    *   An array of tip attributes, keyed by path.
15    *
16    * @code
17    * protected $tips = array(
18    *   '/foo/bar' => array(
19    *     array('data-id' => 'foo'),
20    *     array('data-class' => 'bar'),
21    *   ),
22    * );
23    * @endcode
24    */
25   protected $tips = [];
26
27   /**
28    * An admin user with administrative permissions for tour.
29    *
30    * @var \Drupal\user\UserInterface
31    */
32   protected $adminUser;
33
34   /**
35    * The permissions required for a logged in user to test tour tips.
36    *
37    * @var array
38    *   A list of permissions.
39    */
40   protected $permissions = ['access tour'];
41
42   protected function setUp() {
43     parent::setUp();
44
45     // Make sure we are using distinct default and administrative themes for
46     // the duration of these tests.
47     $this->container->get('theme_handler')->install(['bartik', 'seven']);
48     $this->config('system.theme')
49       ->set('default', 'bartik')
50       ->set('admin', 'seven')
51       ->save();
52
53     $this->permissions[] = 'view the administration theme';
54
55     // Create an admin user to view tour tips.
56     $this->adminUser = $this->drupalCreateUser($this->permissions);
57     $this->drupalLogin($this->adminUser);
58   }
59
60   /**
61    * A simple tip test.
62    */
63   public function testTips() {
64     foreach ($this->tips as $path => $attributes) {
65       $this->drupalGet($path);
66       $this->assertTourTips($attributes);
67     }
68   }
69
70 }