Update to Drupal 8.1.0. For more information, see https://www.drupal.org/drupal-8.1.0-release-notes
This commit is contained in:
parent
b11a755ba8
commit
c0a0d5a94c
6920 changed files with 64395 additions and 57312 deletions
72
core/modules/views_ui/tests/src/Kernel/TagTest.php
Normal file
72
core/modules/views_ui/tests/src/Kernel/TagTest.php
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\views_ui\Kernel;
|
||||
|
||||
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
|
||||
use Drupal\views_ui\Controller\ViewsUIController;
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\views\Entity\View;
|
||||
|
||||
/**
|
||||
* Tests the views ui tagging functionality.
|
||||
*
|
||||
* @group views_ui
|
||||
*/
|
||||
class TagTest extends ViewsKernelTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('views', 'views_ui', 'user');
|
||||
|
||||
/**
|
||||
* Tests the views_ui_autocomplete_tag function.
|
||||
*/
|
||||
public function testViewsUiAutocompleteTag() {
|
||||
\Drupal::moduleHandler()->loadInclude('views_ui', 'inc', 'admin');
|
||||
|
||||
// Save 15 views with a tag.
|
||||
$tags = array();
|
||||
for ($i = 0; $i < 16; $i++) {
|
||||
$suffix = $i % 2 ? 'odd' : 'even';
|
||||
$tag = 'autocomplete_tag_test_' . $suffix . $this->randomMachineName();
|
||||
$tags[] = $tag;
|
||||
View::create(array('tag' => $tag, 'id' => $this->randomMachineName()))->save();
|
||||
}
|
||||
|
||||
// Make sure just ten results are returns.
|
||||
$controller = ViewsUIController::create($this->container);
|
||||
$request = $this->container->get('request_stack')->getCurrentRequest();
|
||||
$request->query->set('q', 'autocomplete_tag_test');
|
||||
$result = $controller->autocompleteTag($request);
|
||||
$matches = (array) json_decode($result->getContent(), TRUE);
|
||||
$this->assertEqual(count($matches), 10, 'Make sure the maximum amount of tag results is 10.');
|
||||
|
||||
// Make sure the returned array has the proper format.
|
||||
$suggestions = array_map(function ($tag) {
|
||||
return array('value' => $tag, 'label' => Html::escape($tag));
|
||||
}, $tags);
|
||||
foreach ($matches as $match) {
|
||||
$this->assertTrue(in_array($match, $suggestions), 'Make sure the returned array has the proper format.');
|
||||
}
|
||||
|
||||
|
||||
// Make sure that matching by a certain prefix works.
|
||||
$request->query->set('q', 'autocomplete_tag_test_even');
|
||||
$result = $controller->autocompleteTag($request);
|
||||
$matches = (array) json_decode($result->getContent(), TRUE);
|
||||
$this->assertEqual(count($matches), 8, 'Make sure that only a subset is returned.');
|
||||
foreach ($matches as $tag) {
|
||||
$this->assertTrue(array_search($tag['value'], $tags) !== FALSE, format_string('Make sure the returned tag @tag actually exists.', array('@tag' => $tag['value'])));
|
||||
}
|
||||
|
||||
// Make sure an invalid result doesn't return anything.
|
||||
$request->query->set('q', $this->randomMachineName());
|
||||
$result = $controller->autocompleteTag($request);
|
||||
$matches = (array) json_decode($result->getContent());
|
||||
$this->assertEqual(count($matches), 0, "Make sure an invalid tag doesn't return anything.");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\views_ui\Unit\Form\Ajax\RearrangeFilterTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\views_ui\Unit\Form\Ajax;
|
||||
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\Tests\views_ui\Unit;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
@ -168,8 +167,6 @@ class ViewListBuilderTest extends UnitTestCase {
|
|||
$display_paths = $row['data']['path']['data']['#items'];
|
||||
// These values will be escaped by Twig when rendered.
|
||||
$this->assertEquals('/test_page, /<object>malformed_path</object>, /<script>alert("placeholder_page/%")</script>', implode(', ', $display_paths));
|
||||
$this->assertFalse(SafeMarkup::isSafe('/<object>malformed_path</object>'), '/<script>alert("/<object>malformed_path</object> is not marked safe.');
|
||||
$this->assertFalse(SafeMarkup::isSafe('/<script>alert("placeholder_page/%")'), '/<script>alert("/<script>alert("placeholder_page/%") is not marked safe.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\views_ui\Unit\ViewUIObjectTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\views_ui\Unit;
|
||||
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
|
|
Reference in a new issue