3 namespace Drupal\Tests\node\Functional\Views;
5 use Drupal\Tests\views\Functional\Wizard\WizardTestBase;
6 use Drupal\views\Views;
9 * Tests the wizard with node_revision as base table.
12 * @see \Drupal\node\Plugin\views\wizard\NodeRevision
14 class NodeRevisionWizardTest extends WizardTestBase {
17 * Tests creating a node revision view.
19 public function testViewAdd() {
20 $this->drupalCreateContentType(['type' => 'article']);
21 // Create two nodes with two revision.
22 $node_storage = \Drupal::entityManager()->getStorage('node');
23 /** @var \Drupal\node\NodeInterface $node */
24 $node = $node_storage->create(['title' => $this->randomString(), 'type' => 'article', 'created' => REQUEST_TIME + 40]);
27 $node = $node->createDuplicate();
28 $node->setNewRevision();
29 $node->created->value = REQUEST_TIME + 20;
32 $node = $node_storage->create(['title' => $this->randomString(), 'type' => 'article', 'created' => REQUEST_TIME + 30]);
35 $node = $node->createDuplicate();
36 $node->setNewRevision();
37 $node->created->value = REQUEST_TIME + 10;
41 $view['label'] = $this->randomMachineName(16);
42 $view['id'] = strtolower($this->randomMachineName(16));
43 $view['description'] = $this->randomMachineName(16);
44 $view['page[create]'] = FALSE;
45 $view['show[wizard_key]'] = 'node_revision';
46 $this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
48 $view_storage_controller = \Drupal::entityManager()->getStorage('view');
49 /** @var \Drupal\views\Entity\View $view */
50 $view = $view_storage_controller->load($view['id']);
52 $this->assertEqual($view->get('base_table'), 'node_field_revision');
54 $executable = Views::executableFactory()->get($view);
55 $this->executeView($executable);
57 $this->assertIdenticalResultset($executable, [['vid' => 1], ['vid' => 3], ['vid' => 2], ['vid' => 4]],