Update to Drupal 8.1.8. For more information, see https://www.drupal.org/project/drupal/releases/8.1.8

This commit is contained in:
Pantheon Automation 2016-08-03 13:22:33 -07:00 committed by Greg Anderson
parent e9f047ccf8
commit f9f23cdf38
312 changed files with 6751 additions and 1546 deletions

View file

@ -114,7 +114,9 @@
Drupal.views.ajaxView.prototype.attachExposedFormAjax = function () {
var that = this;
this.exposedFormAjax = [];
$('input[type=submit], input[type=image]', this.$exposed_form).each(function (index) {
// Exclude the reset buttons so no AJAX behaviours are bound. Many things
// break during the form reset phase if using AJAX.
$('input[type=submit], input[type=image]', this.$exposed_form).not('[data-drupal-selector=edit-reset]').each(function (index) {
var self_settings = $.extend({}, that.element_settings, {
base: $(this).attr('id'),
element: this

View file

@ -9,7 +9,7 @@ use Drupal\node\NodeInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Abstract argument handler for dates.
* Argument handler for dates.
*
* Adds an option to set a default argument based on the current date.
*

View file

@ -6,7 +6,7 @@ use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ViewExecutable;
/**
* Abstract argument handler for simple formulae.
* Argument handler for simple formulae.
*
* Child classes of this object should implement summaryArgument, at least.
*

View file

@ -237,8 +237,8 @@ abstract class PathPluginBase extends DisplayPluginBase implements DisplayRouter
$route_path = RouteCompiler::getPathWithoutDefaults($route);
$route_path = RouteCompiler::getPatternOutline($route_path);
// Ensure that we don't override a route which is already controlled by
// views.
if (!$route->hasDefault('view_id') && ('/' . $view_path == $route_path)) {
// views. Also ensure that we don't override for example REST routes.
if (!$route->hasDefault('view_id') && ('/' . $view_path == $route_path) && (!$route->getMethods() || in_array('GET', $route->getMethods()))) {
$parameters = $route->compile()->getPathVariables();
// @todo Figure out whether we need to merge some settings (like

View file

@ -285,6 +285,14 @@ abstract class QueryPluginBase extends PluginBase implements CacheableDependency
foreach ((array) $this->view->relationship as $relationship_id => $relationship) {
$table_data = $views_data->get($relationship->definition['base']);
if (isset($table_data['table']['entity type'])) {
// If this is not one of the entity base tables, skip it.
$entity_type = \Drupal::entityTypeManager()->getDefinition($table_data['table']['entity type']);
$entity_base_tables = [$entity_type->getBaseTable(), $entity_type->getDataTable(), $entity_type->getRevisionTable(), $entity_type->getRevisionDataTable()];
if (!in_array($relationship->definition['base'], $entity_base_tables)) {
continue;
}
$entity_tables[$relationship_id . '__' . $relationship->tableAlias] = array(
'base' => $relationship->definition['base'],
'relationship_id' => $relationship_id,

View file

@ -168,6 +168,9 @@ class ExposedFormTest extends ViewTestBase {
$this->assertResponse(200);
$this->assertFieldById('edit-type', 'All', 'Article type filter has been reset.');
// Test the button is hidden after reset.
$this->assertNoField('edit-reset');
// Rename the label of the reset button.
$view = Views::getView('test_exposed_form_buttons');
$view->setDisplay();

View file

@ -80,7 +80,7 @@ class BasicTest extends WizardTestBase {
$elements = $this->cssSelect('link[href="' . Url::fromRoute('view.' . $view2['id'] . '.feed_1', [], ['absolute' => TRUE])->toString() . '"]');
$this->assertEqual(count($elements), 1, 'Feed found.');
$this->drupalGet($view2['page[feed_properties][path]']);
$this->assertRaw('<rss version="2.0"');
$this->assertTrue(!empty($this->cssSelect('rss[version="2.0"]')));
// The feed should have the same title and nodes as the page.
$this->assertText($view2['page[title]']);
$this->assertRaw($node1->url('canonical', ['absolute' => TRUE]));

View file

@ -1420,7 +1420,7 @@ class ViewExecutable implements \Serializable {
// Let modules modify the view just after executing it.
$module_handler->invokeAll('views_post_execute', array($this));
$this->executed = TRUE;
return $this->executed = TRUE;
}
/**

View file

@ -55,7 +55,7 @@ class ExposedFilterAJAXTest extends JavascriptTestBase {
// Search for "Page One".
$this->submitForm(['title' => 'Page One'], t('Filter'));
$this->waitForAjaxToFinish();
$this->assertSession()->assertWaitOnAjaxRequest();
// Verify that only the "Page One" Node is present.
$html = $session->getPage()->getHtml();
@ -64,20 +64,20 @@ class ExposedFilterAJAXTest extends JavascriptTestBase {
// Search for "Page Two".
$this->submitForm(['title' => 'Page Two'], t('Filter'));
$this->waitForAjaxToFinish();
$this->assertSession()->assertWaitOnAjaxRequest();
// Verify that only the "Page Two" Node is present.
$html = $session->getPage()->getHtml();
$this->assertContains('Page Two', $html);
$this->assertNotContains('Page One', $html);
}
/**
* Waits for jQuery to become active and animations to complete.
*/
protected function waitForAjaxToFinish() {
$condition = "(0 === jQuery.active && 0 === jQuery(':animated').length)";
$this->assertJsCondition($condition, 10000);
// Reset the form.
$this->submitForm([], t('Reset'));
$this->assertSession()->assertWaitOnAjaxRequest();
$this->assertSession()->pageTextContains('Page One');
$this->assertSession()->pageTextContains('Page Two');
$this->assertFalse($session->getPage()->hasButton('Reset'));
}
}

View file

@ -260,6 +260,44 @@ class PathPluginBaseTest extends UnitTestCase {
$this->assertSame($collection->get('test_route_2'), $route_2);
}
/**
* Tests the altering of a REST route.
*/
public function testAlterRestRoute() {
$collection = new RouteCollection();
$route = new Route('test_route', ['_controller' => 'Drupal\Tests\Core\Controller\TestController::content']);
$route->setMethods(['POST']);
$collection->add('test_route', $route);
list($view) = $this->setupViewExecutableAccessPlugin();
$display = [];
$display['display_plugin'] = 'page';
$display['id'] = 'page_1';
$display['display_options'] = [
'path' => 'test_route',
];
$this->pathPlugin->initDisplay($view, $display);
$this->pathPlugin->collectRoutes($collection);
$view_route_names = $this->pathPlugin->alterRoutes($collection);
$this->assertEquals([], $view_route_names);
// Ensure that the test_route is not overridden.
$this->assertCount(2, $collection);
$route = $collection->get('test_route');
$this->assertTrue($route instanceof Route);
$this->assertFalse($route->hasDefault('view_id'));
$this->assertFalse($route->hasDefault('display_id'));
$this->assertSame($collection->get('test_route'), $route);
$route = $collection->get('view.test_id.page_1');
$this->assertTrue($route instanceof Route);
$this->assertEquals('test_id', $route->getDefault('view_id'));
$this->assertEquals('page_1', $route->getDefault('display_id'));
$this->assertEquals('my views title', $route->getDefault('_title'));
}
/**
* Tests the alter route method with preexisting title callback.
*/

View file

@ -202,6 +202,12 @@ class SqlTest extends UnitTestCase {
'entity revision' => TRUE,
],
]);
$views_data->get('entity_first_field_data')->willReturn([
'table' => [
'entity type' => 'first',
'entity revision' => FALSE,
],
]);
$this->setupViewsData($views_data->reveal());
// Setup the loading of entities and entity revisions.
@ -367,6 +373,55 @@ class SqlTest extends UnitTestCase {
$this->assertSame($entities['second'][12], $result[2]->_relationship_entities['entity_second']);
}
/**
* @covers ::loadEntities
* @covers ::_assignEntitiesToResult
*/
public function testLoadEntitiesWithNonEntityRelationship() {
// We don't use prophecy, because prophecy enforces methods.
$view = $this->getMockBuilder(ViewExecutable::class)->disableOriginalConstructor()->getMock();
$this->setupViewWithRelationships($view, 'entity_first_field_data');
$view_entity = $this->prophesize(ViewEntityInterface::class);
$view_entity->get('base_table')->willReturn('entity_first');
$view_entity->get('base_field')->willReturn('id');
$view->storage = $view_entity->reveal();
$entities = [
'first' => [
1 => $this->prophesize(EntityInterface::class)->reveal(),
2 => $this->prophesize(EntityInterface::class)->reveal(),
],
];
$entity_type_manager = $this->setupEntityTypes($entities);
$query = new Sql([], 'sql', [], $entity_type_manager->reveal());
$query->view = $view;
$result = [];
$result[] = new ResultRow([
'id' => 1,
]);
$result[] = new ResultRow([
'id' => 2,
]);
$query->addField('entity_first', 'id', 'id');
$query->loadEntities($result);
$entity_information = $query->getEntityTableInfo();
$this->assertSame($entities['first'][1], $result[0]->_entity);
$this->assertSame($entities['first'][2], $result[1]->_entity);
$this->assertEquals([], $result[0]->_relationship_entities);
$this->assertEquals([], $result[1]->_relationship_entities);
// This is an entity table and should be in $entity_information.
$this->assertContains('first', array_keys($entity_information));
// This is not an entity table and should not be in $entity_information.
$this->assertNotContains('entity_first_field_data__entity_first_field_data', array_keys($entity_information));
}
/**
* @covers ::loadEntities
* @covers ::_assignEntitiesToResult

View file

@ -21,6 +21,16 @@ use Symfony\Component\Routing\Route;
*/
class ViewExecutableTest extends UnitTestCase {
/**
* Indicates that a display is enabled.
*/
const DISPLAY_ENABLED = TRUE;
/**
* Indicates that a display is disabled.
*/
const DISPLAY_DISABLED = FALSE;
/**
* A mocked display collection.
*
@ -632,4 +642,52 @@ class ViewExecutableTest extends UnitTestCase {
$view->execute();
}
/**
* Tests the return values for the execute() method.
*
* @param bool $display_enabled
* Whether the display to test should be enabled.
* @param bool $expected_result
* The expected result when calling execute().
*
* @covers ::execute
* @dataProvider providerExecuteReturn
*/
public function testExecuteReturn($display_enabled, $expected_result) {
/** @var \Drupal\views\ViewExecutable|\PHPUnit_Framework_MockObject_MockObject $view */
/** @var \Drupal\views\Plugin\views\display\DisplayPluginBase|\PHPUnit_Framework_MockObject_MockObject $display */
list($view, $display) = $this->setupBaseViewAndDisplay();
$display->expects($this->any())
->method('isEnabled')
->willReturn($display_enabled);
// Pager needs to be set to avoid false test failures.
$view->pager = $this->getMockBuilder(NonePager::class)
->disableOriginalConstructor()
->getMock();
$query = $this->getMockBuilder(QueryPluginBase::class)
->disableOriginalConstructor()
->getMock();
$view->query = $query;
$view->built = TRUE;
$this->assertEquals($expected_result, $view->execute());
}
/**
* Provider for testExecuteReturn().
*
* @return array[]
* An array of arrays containing the display state and expected value.
*/
public function providerExecuteReturn() {
return [
'enabled' => [static::DISPLAY_ENABLED, TRUE],
'disabled' => [static::DISPLAY_DISABLED, FALSE],
];
}
}