X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fviews%2Fsrc%2FTests%2FViewAjaxTest.php;fp=web%2Fcore%2Fmodules%2Fviews%2Fsrc%2FTests%2FViewAjaxTest.php;h=0000000000000000000000000000000000000000;hp=820d9e2bc040fb3cd805ce2191119922424fb11d;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/views/src/Tests/ViewAjaxTest.php b/web/core/modules/views/src/Tests/ViewAjaxTest.php deleted file mode 100644 index 820d9e2bc..000000000 --- a/web/core/modules/views/src/Tests/ViewAjaxTest.php +++ /dev/null @@ -1,74 +0,0 @@ -enableViewsTestModule(); - } - - /** - * Tests an ajax view. - */ - public function testAjaxView() { - $this->drupalGet('test_ajax_view'); - - $drupal_settings = $this->getDrupalSettings(); - $this->assertTrue(isset($drupal_settings['views']['ajax_path']), 'The Ajax callback path is set in drupalSettings.'); - $this->assertEqual(count($drupal_settings['views']['ajaxViews']), 1); - $view_entry = array_keys($drupal_settings['views']['ajaxViews'])[0]; - $this->assertEqual($drupal_settings['views']['ajaxViews'][$view_entry]['view_name'], 'test_ajax_view', 'The view\'s ajaxViews array entry has the correct \'view_name\' key.'); - $this->assertEqual($drupal_settings['views']['ajaxViews'][$view_entry]['view_display_id'], 'page_1', 'The view\'s ajaxViews array entry has the correct \'view_display_id\' key.'); - - $data = []; - $data['view_name'] = 'test_ajax_view'; - $data['view_display_id'] = 'test_ajax_view'; - - $post = [ - 'view_name' => 'test_ajax_view', - 'view_display_id' => 'page_1', - ]; - $post += $this->getAjaxPageStatePostData(); - $response = $this->drupalPost('views/ajax', '', $post, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]); - $data = Json::decode($response); - - $this->assertTrue(isset($data[0]['settings']['views']['ajaxViews'])); - - // Ensure that the view insert command is part of the result. - $this->assertEqual($data[1]['command'], 'insert'); - $this->assertTrue(strpos($data[1]['selector'], '.js-view-dom-id-') === 0); - - $this->setRawContent($data[1]['data']); - $result = $this->xpath('//div[contains(@class, "views-row")]'); - $this->assertEqual(count($result), 2, 'Ensure that two items are rendered in the HTML.'); - } - - /** - * Ensures that non-ajax view cannot be accessed via an ajax HTTP request. - */ - public function testNonAjaxViewViaAjax() { - $this->drupalPost('views/ajax', '', ['view_name' => 'test_ajax_view', 'view_display_id' => 'default'], ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]); - $this->assertResponse(200); - $this->drupalPost('views/ajax', '', ['view_name' => 'test_view', 'view_display_id' => 'default'], ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]); - $this->assertResponse(403); - } - -}