Backup of db before drupal security update
[yaffs-website] / web / core / modules / taxonomy / tests / src / Functional / Views / RelationshipNodeTermDataTest.php
1 <?php
2
3 namespace Drupal\Tests\taxonomy\Functional\Views;
4
5 use Drupal\views\Views;
6
7 /**
8  * Tests the taxonomy term on node relationship handler.
9  *
10  * @group taxonomy
11  */
12 class RelationshipNodeTermDataTest extends TaxonomyTestBase {
13
14   /**
15    * Views used by this test.
16    *
17    * @var array
18    */
19   public static $testViews = ['test_taxonomy_node_term_data'];
20
21   public function testViewsHandlerRelationshipNodeTermData() {
22     $view = Views::getView('test_taxonomy_node_term_data');
23     // Tests \Drupal\taxonomy\Plugin\views\relationship\NodeTermData::calculateDependencies().
24     $expected = [
25       'config' => ['core.entity_view_mode.node.teaser'],
26       'module' => [
27         'node',
28         'taxonomy',
29         'user',
30       ],
31     ];
32     $this->assertIdentical($expected, $view->getDependencies());
33     $this->executeView($view, [$this->term1->id(), $this->term2->id()]);
34     $expected_result = [
35       [
36         'nid' => $this->nodes[1]->id(),
37       ],
38       [
39         'nid' => $this->nodes[0]->id(),
40       ],
41     ];
42     $column_map = ['nid' => 'nid'];
43     $this->assertIdenticalResultset($view, $expected_result, $column_map);
44
45     // Change the view to test relation limited by vocabulary.
46     $this->config('views.view.test_taxonomy_node_term_data')
47       ->set('display.default.display_options.relationships.term_node_tid.vids', ['views_testing_tags'])
48       ->save();
49
50     $view = Views::getView('test_taxonomy_node_term_data');
51     // Tests \Drupal\taxonomy\Plugin\views\relationship\NodeTermData::calculateDependencies().
52     $expected['config'][] = 'taxonomy.vocabulary.views_testing_tags';
53     $this->assertIdentical($expected, $view->getDependencies());
54     $this->executeView($view, [$this->term1->id(), $this->term2->id()]);
55     $this->assertIdenticalResultset($view, $expected_result, $column_map);
56   }
57
58 }