Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / draggableviews / tests / src / Functional / DraggableviewsTest.php
1 <?php
2
3 namespace Drupal\Tests\draggableviews\Functional;
4
5 use Drupal\Tests\BrowserTestBase;
6
7 /**
8  * Tests sortability of Draggableviewws.
9  *
10  * @group draggableviews
11  */
12 class DraggableviewsTest extends BrowserTestBase {
13   /**
14    * Modules to enable.
15    *
16    * @var array
17    */
18   public static $modules = [
19     'node',
20     'views',
21     'draggableviews',
22     'draggableviews_demo',
23   ];
24
25   /**
26    * The installation profile to use with this test.
27    *
28    * @var string
29    */
30   protected $profile = 'minimal';
31
32   /**
33    * {@inheritdoc}
34    */
35   public function setUp() {
36     parent::setUp();
37
38     // Create users.
39     $this->adminUser = $this->drupalCreateUser([
40       'access administration pages',
41       'view the administration theme',
42       'administer permissions',
43       'administer nodes',
44       'administer content types',
45       'access draggableviews',
46     ]);
47     $this->authUser = $this->drupalCreateUser([], 'authuser');
48
49     // Gather the test data.
50     $dataContent = $this->providerTestDataContent();
51
52     // Create nodes.
53     foreach ($dataContent as $datumContent) {
54       $node = $this->drupalCreateNode([
55         'type' => 'draggableviews_demo',
56         'title' => $datumContent[0],
57       ]);
58       $node->save();
59     }
60   }
61
62   /**
63    * Data provider for setUp.
64    *
65    * @return array
66    *   Nested array of testing data, Arranged like this:
67    *   - Title
68    *   - Body
69    */
70   protected function providerTestDataContent() {
71     return [
72       [
73         'Draggable Content 1',
74         'Draggable Content Body 1',
75       ],
76       [
77         'Draggable Content 2',
78         'Draggable Content Body 2',
79       ],
80       [
81         'Draggable Content 3',
82         'Draggable Content Body 3',
83       ],
84       [
85         'Draggable Content 4',
86         'Draggable Content Body 4',
87       ],
88       [
89         'Draggable Content 5',
90         'Draggable Content Body 5',
91       ],
92     ];
93   }
94
95   /**
96    * A simple test.
97    */
98   public function testDraggableviewsContent() {
99     $assert_session = $this->assertSession();
100
101     $this->drupalGet('draggableviews-demo');
102     $this->assertSession()->statusCodeEquals(200);
103     // Verify that anonymous useres cannot access the order page.
104     $this->drupalGet('draggableviews-demo/order');
105     $this->assertSession()->statusCodeEquals(403);
106
107     // Verify that authorized user has access to display page.
108     $this->drupalLogin($this->adminUser);
109     $this->drupalGet('draggableviews-demo');
110     $this->assertSession()->statusCodeEquals(200);
111
112     // Verify that the page contains generated content.
113     $assert_session->pageTextContains(t('Draggable Content 4'));
114
115     // Verify that authorized user has access to order page.
116     $this->drupalGet('draggableviews-demo/order');
117     $this->assertSession()->statusCodeEquals(200);
118
119     // Verify that the page contains generated content.
120     $assert_session->pageTextContains(t('Draggable Content 5'));
121   }
122
123 }