public function ViewStorageTest::testCreateDuplicate in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/src/Tests/ViewStorageTest.php \Drupal\views\Tests\ViewStorageTest::testCreateDuplicate()
Tests the createDuplicate() View method.
File
- core/
modules/ views/ src/ Tests/ ViewStorageTest.php, line 324 - Contains \Drupal\views\Tests\ViewStorageTest.
Class
- ViewStorageTest
- Tests the CRUD functionality for a view.
Namespace
Drupal\views\TestsCode
public function testCreateDuplicate() {
$view = Views::getView('test_view_storage');
$copy = $view->storage
->createDuplicate();
$this
->assertTrue($copy instanceof View, 'The copied object is a View.');
// Check that the original view and the copy have different UUIDs.
$this
->assertNotIdentical($view->storage
->uuid(), $copy
->uuid(), 'The copied view has a new UUID.');
// Check the 'name' (ID) is using the View objects default value (NULL) as it
// gets unset.
$this
->assertIdentical($copy
->id(), NULL, 'The ID has been reset.');
// Check the other properties.
// @todo Create a reusable property on the base test class for these?
$config_properties = array(
'disabled',
'description',
'tag',
'base_table',
'label',
'core',
);
foreach ($config_properties as $property) {
$this
->assertIdentical($view->storage
->get($property), $copy
->get($property), format_string('@property property is identical.', array(
'@property' => $property,
)));
}
// Check the displays are the same.
$copy_display = $copy
->get('display');
foreach ($view->storage
->get('display') as $id => $display) {
// assertIdentical will not work here.
$this
->assertEqual($display, $copy_display[$id], format_string('The @display display has been copied correctly.', array(
'@display' => $id,
)));
}
}