Update to Drupal 8.0.2. For more information, see https://www.drupal.org/drupal-8.0.2-release-notes

This commit is contained in:
Pantheon Automation 2016-01-06 16:31:26 -08:00 committed by Greg Anderson
parent 1a0e9d9fac
commit a6b049dd05
538 changed files with 5247 additions and 1594 deletions

View file

@ -19,6 +19,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\ReplaceCommand;
use Drupal\Component\Utility\Html;
/**
* Returns responses for Views UI routes.
@ -189,12 +190,17 @@ class ViewsUIController extends ControllerBase {
$string = $request->query->get('q');
// Get matches from default views.
$views = $this->entityManager()->getStorage('view')->loadMultiple();
// Keep track of previously processed tags so they can be skipped.
$tags = [];
foreach ($views as $view) {
$tag = $view->get('tag');
if ($tag && strpos($tag, $string) === 0) {
$matches[$tag] = $tag;
if (count($matches) >= 10) {
break;
if ($tag && !in_array($tag, $tags)) {
$tags[] = $tag;
if (strpos($tag, $string) === 0) {
$matches[] = ['value' => $tag, 'label' => Html::escape($tag)];
if (count($matches) >= 10) {
break;
}
}
}
}

View file

@ -142,6 +142,23 @@ class DefaultViewsTest extends UITestBase {
$this->drupalGet($edit_href);
$this->assertResponse(404);
$this->assertText('Page not found');
// Delete all duplicated Glossary views.
$this->drupalGet('admin/structure/views');
$this->clickViewsOperationLink(t('Delete'), 'duplicate_of_glossary');
// Submit the confirmation form.
$this->drupalPostForm(NULL, array(), t('Delete'));
$this->drupalGet('glossary');
$this->assertResponse(200);
$this->drupalGet('admin/structure/views');
$this->clickViewsOperationLink(t('Delete'), $random_name);
// Submit the confirmation form.
$this->drupalPostForm(NULL, array(), t('Delete'));
$this->drupalGet('glossary');
$this->assertResponse(404);
$this->assertText('Page not found');
}
/**

View file

@ -92,6 +92,26 @@ class FilterNumericWebTest extends UITestBase {
$this->assertNoText('Ringo');
$this->assertNoText('George');
$this->assertNoText('Meredith');
// Change the filter to a 'between' filter to test if the label and
// description are set for the 'minimum' filter element.
$this->drupalGet('admin/structure/views/nojs/handler/test_view/default/filter/age');
$edit = array();
$edit['options[expose][label]'] = 'Age between';
$edit['options[expose][description]'] = 'Description of the exposed filter';
$edit['options[operator]'] = 'between';
$edit['options[value][min]'] = 26;
$edit['options[value][max]'] = 28;
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->drupalPostForm('admin/structure/views/view/test_view', array(), t('Save'));
$this->assertConfigSchemaByName('views.view.test_view');
$this->drupalPostForm(NULL, array(), t('Update preview'));
// Check the max field label.
$this->assertRaw('<label for="edit-age-max">And</label>', 'Max field label found');
$this->assertRaw('<label for="edit-age-min">Age between</label>', 'Min field label found');
// Check that the description is shown in the right place.
$this->assertEqual(trim($this->cssSelect('.form-item-age-min .description')[0]), 'Description of the exposed filter');
}
}

View file

@ -21,7 +21,7 @@ class PreviewTest extends UITestBase {
*
* @var array
*/
public static $testViews = array('test_preview', 'test_pager_full', 'test_mini_pager');
public static $testViews = array('test_preview', 'test_preview_error', 'test_pager_full', 'test_mini_pager');
/**
* Tests contextual links in the preview form.
@ -90,6 +90,34 @@ class PreviewTest extends UITestBase {
$this->drupalPostForm(NULL, array(), t('Update preview'));
$result = $this->xpath('//div[@id="views-live-preview"]/pre');
$this->assertTrue(strpos($result[0], '<title>' . $view['page[title]'] . '</title>'), 'The Feed RSS preview was rendered.');
// Test the non-default UI display options.
// Statistics only, no query.
$settings = \Drupal::configFactory()->getEditable('views.settings');
$settings->set('ui.show.performance_statistics', TRUE)->save();
$this->drupalGet('admin/structure/views/view/test_preview/edit');
$this->drupalPostForm(NULL, $edit = array('view_args' => '100'), t('Update preview'));
$this->assertText(t('Query build time'));
$this->assertText(t('Query execute time'));
$this->assertText(t('View render time'));
$this->assertNoRaw('<strong>Query</strong>');
// Statistics and query.
$settings->set('ui.show.sql_query.enabled', TRUE)->save();
$this->drupalPostForm(NULL, $edit = array('view_args' => '100'), t('Update preview'));
$this->assertText(t('Query build time'));
$this->assertText(t('Query execute time'));
$this->assertText(t('View render time'));
$this->assertRaw('<strong>Query</strong>');
$this->assertText("SELECT views_test_data.name AS views_test_data_name\nFROM \n{views_test_data} views_test_data\nWHERE (( (views_test_data.id = &#039;100&#039; ) ))");
// Test that the statistics and query are rendered above the preview.
$this->assertTrue(strpos($this->getRawContent(), 'views-query-info') < strpos($this->getRawContent(), 'view-test-preview') , 'Statistics shown above the preview.');
// Test that statistics and query rendered below the preview.
$settings->set('ui.show.sql_query.where', 'below')->save();
$this->drupalPostForm(NULL, $edit = array('view_args' => '100'), t('Update preview'));
$this->assertTrue(strpos($this->getRawContent(), 'view-test-preview') < strpos($this->getRawContent(), 'views-query-info'), 'Statistics shown below the preview.');
}
/**
@ -230,6 +258,18 @@ class PreviewTest extends UITestBase {
$this->assertRaw('css/views_ui_test.test.css', 'Attached CSS asset found.');
}
/**
* Tests view validation error messages in the preview.
*/
public function testPreviewError() {
$this->drupalGet('admin/structure/views/view/test_preview_error/edit');
$this->assertResponse(200);
$this->drupalPostForm(NULL, $edit = array(), t('Update preview'));
$this->assertText('Unable to preview due to validation errors.', 'Preview error text found.');
}
/**
* Get the preview form and force an AJAX preview update.
*

View file

@ -9,6 +9,7 @@ namespace Drupal\views_ui\Tests;
use Drupal\views\Tests\ViewKernelTestBase;
use Drupal\views_ui\Controller\ViewsUIController;
use Drupal\Component\Utility\Html;
/**
* Tests the views ui tagging functionality.
@ -44,16 +45,25 @@ class TagTest extends ViewKernelTestBase {
$request = $this->container->get('request_stack')->getCurrentRequest();
$request->query->set('q', 'autocomplete_tag_test');
$result = $controller->autocompleteTag($request);
$matches = (array) json_decode($result->getContent());
$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());
$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, $tags) !== FALSE, format_string('Make sure the returned tag @tag actually exists.', array('@tag' => $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.

View file

@ -45,26 +45,12 @@ class ViewUI implements ViewEntityInterface {
public $changed_display;
/**
* How long the view takes to build.
* How long the view takes to render in microseconds.
*
* @var int
*/
public $build_time;
/**
* How long the view takes to render.
*
* @var int
* @var float
*/
public $render_time;
/**
* How long the view takes to execute.
*
* @var int
*/
public $execute_time;
/**
* If this view is locked for editing.
*
@ -636,12 +622,15 @@ class ViewUI implements ViewEntityInterface {
$this->endQueryCapture();
}
$this->render_time = Timer::stop('entity.view.preview_form');
$this->render_time = Timer::stop('entity.view.preview_form')['time'];
views_ui_contextual_links_suppress_pop();
// Prepare the query information and statistics to show either above or
// below the view preview.
// Initialise the empty rows arrays so we can safely merge them later.
$rows['query'] = [];
$rows['statistics'] = [];
if ($show_info || $show_query || $show_stats) {
// Get information from the preview for display.
if (!empty($executable->build_info['query'])) {
@ -769,7 +758,7 @@ class ViewUI implements ViewEntityInterface {
'#template' => "<strong>{% trans 'View render time' %}</strong>",
),
),
t('@time ms', array('@time' => intval($executable->render_time * 100000) / 100)),
t('@time ms', array('@time' => intval($this->render_time * 100) / 100)),
);
}
\Drupal::moduleHandler()->alter('views_preview_info', $rows, $executable);
@ -818,7 +807,7 @@ class ViewUI implements ViewEntityInterface {
drupal_set_message($error, 'error');
}
}
$preview = t('Unable to preview due to validation errors.');
$preview = ['#markup' => t('Unable to preview due to validation errors.')];
}
// Assemble the preview, the query info, and the query statistics in the
@ -827,26 +816,16 @@ class ViewUI implements ViewEntityInterface {
'#type' => 'table',
'#prefix' => '<div class="views-query-info">',
'#suffix' => '</div>',
'#rows' => array_merge($rows['query'], $rows['statistics']),
);
if ($show_location === 'above' || $show_location === 'below') {
if ($combined) {
$table['#rows'] = array_merge($rows['query'], $rows['statistics']);
}
else {
$table['#rows'] = $rows['query'];
}
}
elseif ($show_stats === 'above' || $show_stats === 'below') {
$table['#rows'] = $rows['statistics'];
}
if ($show_location === 'above' || $show_stats === 'above') {
if ($show_location == 'above') {
$output = [
'table' => $table,
'preview' => $preview,
];
}
elseif ($show_location === 'below' || $show_stats === 'below') {
else {
$output = [
'preview' => $preview,
'table' => $table,