NodeRevisionWizardTest.php in Zircon Profile 8.0
File
core/modules/node/src/Tests/Views/NodeRevisionWizardTest.php
View source
<?php
namespace Drupal\node\Tests\Views;
use Drupal\views\Tests\Wizard\WizardTestBase;
use Drupal\views\Views;
class NodeRevisionWizardTest extends WizardTestBase {
public function testViewAdd() {
$this
->drupalCreateContentType(array(
'type' => 'article',
));
$node_storage = \Drupal::entityManager()
->getStorage('node');
$node = $node_storage
->create(array(
'title' => $this
->randomString(),
'type' => 'article',
'created' => REQUEST_TIME + 40,
));
$node
->save();
$node = $node
->createDuplicate();
$node
->setNewRevision();
$node->created->value = REQUEST_TIME + 20;
$node
->save();
$node = $node_storage
->create(array(
'title' => $this
->randomString(),
'type' => 'article',
'created' => REQUEST_TIME + 30,
));
$node
->save();
$node = $node
->createDuplicate();
$node
->setNewRevision();
$node->created->value = REQUEST_TIME + 10;
$node
->save();
$view = array();
$view['label'] = $this
->randomMachineName(16);
$view['id'] = strtolower($this
->randomMachineName(16));
$view['description'] = $this
->randomMachineName(16);
$view['page[create]'] = FALSE;
$view['show[wizard_key]'] = 'node_revision';
$this
->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
$view_storage_controller = \Drupal::entityManager()
->getStorage('view');
$view = $view_storage_controller
->load($view['id']);
$this
->assertEqual($view
->get('base_table'), 'node_field_revision');
$executable = Views::executableFactory()
->get($view);
$this
->executeView($executable);
$this
->assertIdenticalResultset($executable, array(
array(
'vid' => 1,
),
array(
'vid' => 3,
),
array(
'vid' => 2,
),
array(
'vid' => 4,
),
), array(
'vid' => 'vid',
));
}
}