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:
parent
e9f047ccf8
commit
f9f23cdf38
312 changed files with 6751 additions and 1546 deletions
|
@ -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'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue