Tests the initDisplay() and initHandlers() methods.
public function testInitMethods() {
$view = views_get_view('test_destroy');
$view
->initDisplay();
$this
->assertTrue($view->display_handler instanceof DefaultDisplay, 'Make sure a reference to the current display handler is set.');
$this
->assertTrue($view->displayHandlers
->get('default') instanceof DefaultDisplay, 'Make sure a display handler is created for each display.');
$view
->destroy();
$view
->initHandlers();
// Check for all handler types.
$handler_types = array_keys(ViewExecutable::viewsHandlerTypes());
foreach ($handler_types as $type) {
// The views_test integration doesn't have relationships.
if ($type == 'relationship') {
continue;
}
$this
->assertTrue(count($view->{$type}), format_string('Make sure a %type instance got instantiated.', array(
'%type' => $type,
)));
}
// initHandlers() should create display handlers automatically as well.
$this
->assertTrue($view->display_handler instanceof DefaultDisplay, 'Make sure a reference to the current display handler is set.');
$this
->assertTrue($view->displayHandlers
->get('default') instanceof DefaultDisplay, 'Make sure a display handler is created for each display.');
$view_hash = spl_object_hash($view);
$display_hash = spl_object_hash($view->display_handler);
// Test the initStyle() method.
$view
->initStyle();
$this
->assertTrue($view->style_plugin instanceof DefaultStyle, 'Make sure a reference to the style plugin is set.');
// Test the plugin has been inited and view have references to the view and
// display handler.
$this
->assertEqual(spl_object_hash($view->style_plugin->view), $view_hash);
$this
->assertEqual(spl_object_hash($view->style_plugin->displayHandler), $display_hash);
// Test the initQuery method().
$view
->initQuery();
$this
->assertTrue($view->query instanceof Sql, 'Make sure a reference to the query is set');
$this
->assertEqual(spl_object_hash($view->query->view), $view_hash);
$this
->assertEqual(spl_object_hash($view->query->displayHandler), $display_hash);
}