diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php b/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php index 86da14f..8f3bc6b 100644 --- a/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php @@ -7,10 +7,12 @@ namespace Drupal\views\Tests; +use Symfony\Component\HttpFoundation\Response; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DefaultDisplay; use Drupal\views\Plugin\views\display\Page; use Drupal\views\Plugin\views\style\DefaultStyle; +use Drupal\views\Plugin\views\query\Sql; /** * Tests the ViewExecutable class. @@ -106,13 +108,22 @@ public function testInitMethods() { $this->assertTrue($view->display_handler instanceof DefaultDisplay, 'Make sure a reference to the current display handler is set.'); $this->assertTrue($view->displayHandlers['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), spl_object_hash($view)); - $this->assertEqual(spl_object_hash($view->style_plugin->displayHandler), spl_object_hash($view->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); } /** @@ -177,7 +188,7 @@ public function testDisplays() { /** * Tests the setting/getting of properties. */ - public function testPropertySettings() { + public function testPropertyMethods() { $view = views_get_view('test_executable_displays'); // Test the setUseAJAX() method. @@ -208,6 +219,44 @@ public function testPropertySettings() { '#global' => TRUE, ); $this->assertIdentical($view->getBaseTables(), $expected); + + // Test response methods. + $this->assertTrue($view->getResponse() instanceof Response, 'New response object returned.'); + $new_response = new Response(); + $view->setResponse($new_response); + $this->assertIdentical(spl_object_hash($view->getResponse()), spl_object_hash($new_response), 'New response object correctly set.'); + + // Test the generateItemId() method. + $test_ids = drupal_map_assoc(array('test', 'test_1')); + $this->assertEqual($view->generateItemId('new', $test_ids), 'new'); + $this->assertEqual($view->generateItemId('test', $test_ids), 'test_2'); + + // Test the getPath() method. + $path = $this->randomString(10); + $view->displayHandlers['page_1']->overrideOption('path', $path); + $view->setDisplay('page_1'); + $this->assertEqual($view->getPath(), $path); + // Test the override_path property override. + $override_path = $this->randomString(10); + $view->override_path = $override_path; + $this->assertEqual($view->getPath(), $override_path); + + // Test the getUrl method(). + $url = $this->randomString(10); + $this->assertEqual($view->getUrl(NULL, $url), $url); + // Test with arguments. + $arg1 = $this->randomString(10); + $arg2 = rand(); + $this->assertEqual($view->getUrl(array($arg1, $arg2), $url), "$url/$arg1/$arg2"); + // Test the override_url property override. + $override_url = $this->randomString(10); + $view->override_url = $override_url; + $this->assertEqual($view->getUrl(NULL, $url), $override_url); + + // Test the title methods. + $title = $this->randomString(10); + $view->setTitle($title); + $this->assertEqual($view->getTitle(), $title); } /**