Mercurial > hg > isophonics-drupal-site
comparison core/modules/node/tests/src/Functional/NodeAdminTest.php @ 18:af1871eacc83
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:33:08 +0100 |
parents | 4c8ae668cc8c |
children |
comparison
equal
deleted
inserted
replaced
17:129ea1e6d783 | 18:af1871eacc83 |
---|---|
1 <?php | 1 <?php |
2 | 2 |
3 namespace Drupal\Tests\node\Functional; | 3 namespace Drupal\Tests\node\Functional; |
4 | 4 |
5 use Drupal\Core\Database\Database; | |
5 use Drupal\user\RoleInterface; | 6 use Drupal\user\RoleInterface; |
6 | 7 |
7 /** | 8 /** |
8 * Tests node administration page functionality. | 9 * Tests node administration page functionality. |
9 * | 10 * |
64 */ | 65 */ |
65 public function testContentAdminSort() { | 66 public function testContentAdminSort() { |
66 $this->drupalLogin($this->adminUser); | 67 $this->drupalLogin($this->adminUser); |
67 | 68 |
68 $changed = REQUEST_TIME; | 69 $changed = REQUEST_TIME; |
70 $connection = Database::getConnection(); | |
69 foreach (['dd', 'aa', 'DD', 'bb', 'cc', 'CC', 'AA', 'BB'] as $prefix) { | 71 foreach (['dd', 'aa', 'DD', 'bb', 'cc', 'CC', 'AA', 'BB'] as $prefix) { |
70 $changed += 1000; | 72 $changed += 1000; |
71 $node = $this->drupalCreateNode(['title' => $prefix . $this->randomMachineName(6)]); | 73 $node = $this->drupalCreateNode(['title' => $prefix . $this->randomMachineName(6)]); |
72 db_update('node_field_data') | 74 $connection->update('node_field_data') |
73 ->fields(['changed' => $changed]) | 75 ->fields(['changed' => $changed]) |
74 ->condition('nid', $node->id()) | 76 ->condition('nid', $node->id()) |
75 ->execute(); | 77 ->execute(); |
76 } | 78 } |
77 | 79 |
78 // Test that the default sort by node.changed DESC actually fires properly. | 80 // Test that the default sort by node.changed DESC actually fires properly. |
79 $nodes_query = db_select('node_field_data', 'n') | 81 $nodes_query = $connection->select('node_field_data', 'n') |
80 ->fields('n', ['title']) | 82 ->fields('n', ['title']) |
81 ->orderBy('changed', 'DESC') | 83 ->orderBy('changed', 'DESC') |
82 ->execute() | 84 ->execute() |
83 ->fetchCol(); | 85 ->fetchCol(); |
84 | 86 |
88 $this->assertTrue(!empty($elements), 'The node was found in the correct order.'); | 90 $this->assertTrue(!empty($elements), 'The node was found in the correct order.'); |
89 } | 91 } |
90 | 92 |
91 // Compare the rendered HTML node list to a query for the nodes ordered by | 93 // Compare the rendered HTML node list to a query for the nodes ordered by |
92 // title to account for possible database-dependent sort order. | 94 // title to account for possible database-dependent sort order. |
93 $nodes_query = db_select('node_field_data', 'n') | 95 $nodes_query = $connection->select('node_field_data', 'n') |
94 ->fields('n', ['title']) | 96 ->fields('n', ['title']) |
95 ->orderBy('title') | 97 ->orderBy('title') |
96 ->execute() | 98 ->execute() |
97 ->fetchCol(); | 99 ->fetchCol(); |
98 | 100 |