Update to Drupal 8.0.5. For more information, see https://www.drupal.org/node/2679347

This commit is contained in:
Pantheon Automation 2016-03-02 12:40:24 -08:00 committed by Greg Anderson
parent 2a9f1f148d
commit fd3b12cf27
251 changed files with 5439 additions and 957 deletions

View file

@ -282,16 +282,21 @@ class EntityViewsDataTest extends UnitTestCase {
// Ensure the join information is set up properly.
// Tests the join definition between the base and the revision table.
$revision_data = $data['entity_test_mulrev_property_revision'];
$this->assertCount(2, $revision_data['table']['join']);
$revision_field_data = $data['entity_test_mulrev_property_revision'];
$this->assertCount(1, $revision_field_data['table']['join']);
$this->assertEquals([
'entity_test_mul_property_data' => [
'left_field' => 'revision_id', 'field' => 'revision_id', 'type' => 'INNER'
],
'entity_test_mulrev_revision' => [
], $revision_field_data['table']['join']);
$revision_base_data = $data['entity_test_mulrev_revision'];
$this->assertCount(1, $revision_base_data['table']['join']);
$this->assertEquals([
'entity_test_mulrev_property_revision' => [
'left_field' => 'revision_id', 'field' => 'revision_id', 'type' => 'INNER'
],
], $revision_data['table']['join']);
], $revision_base_data['table']['join']);
$this->assertFalse(isset($data['data_table']));
}
@ -321,12 +326,21 @@ class EntityViewsDataTest extends UnitTestCase {
// Ensure the join information is set up properly.
// Tests the join definition between the base and the revision table.
$revision_data = $data['entity_test_mulrev_property_revision'];
$this->assertCount(2, $revision_data['table']['join']);
$revision_field_data = $data['entity_test_mulrev_property_revision'];
$this->assertCount(1, $revision_field_data['table']['join']);
$this->assertEquals([
'entity_test_mulrev_field_data' => ['left_field' => 'revision_id', 'field' => 'revision_id', 'type' => 'INNER'],
'entity_test_mulrev_revision' => ['left_field' => 'revision_id', 'field' => 'revision_id', 'type' => 'INNER'],
], $revision_data['table']['join']);
'entity_test_mulrev_field_data' => [
'left_field' => 'revision_id', 'field' => 'revision_id', 'type' => 'INNER'
],
], $revision_field_data['table']['join']);
$revision_base_data = $data['entity_test_mulrev_revision'];
$this->assertCount(1, $revision_base_data['table']['join']);
$this->assertEquals([
'entity_test_mulrev_property_revision' => [
'left_field' => 'revision_id', 'field' => 'revision_id', 'type' => 'INNER'
],
], $revision_base_data['table']['join']);
$this->assertFalse(isset($data['data_table']));
}

View file

@ -343,6 +343,8 @@ class FieldPluginBaseTest extends UnitTestCase {
// External URL.
$data[] = ['https://www.drupal.org', [], [], '<a href="https://www.drupal.org">value</a>'];
$data[] = ['www.drupal.org', ['external' => TRUE], [], '<a href="http://www.drupal.org">value</a>'];
$data[] = ['', ['external' => TRUE], [], 'value'];
return $data;
}
@ -510,7 +512,7 @@ class FieldPluginBaseTest extends UnitTestCase {
$build =[
'#type' => 'inline_template',
'#template' => 'base:test-path/' . explode('/', $path)[1],
'#template' => 'test-path/' . explode('/', $path)[1],
'#context' => ['foo' => 123],
'#post_render' => [function() {}],
];
@ -549,6 +551,62 @@ class FieldPluginBaseTest extends UnitTestCase {
return $data;
}
/**
* Test rendering of a link with a path and options.
*
* @dataProvider providerTestRenderAsExternalLinkWithPathAndTokens
* @covers ::renderAsLink
*/
public function testRenderAsExternalLinkWithPathAndTokens($path, $tokens, $link_html, $context) {
$alter = [
'make_link' => TRUE,
'path' => $path,
'url' => '',
];
if (isset($context['alter'])) {
$alter += $context['alter'];
}
$this->setUpUrlIntegrationServices();
$this->setupDisplayWithEmptyArgumentsAndFields();
$this->executable->build_info['substitutions'] = $tokens;
$field = $this->setupTestField(['alter' => $alter]);
$field->field_alias = 'key';
$row = new ResultRow(['key' => 'value']);
$build = [
'#type' => 'inline_template',
'#template' => $path,
'#context' => ['foo' => $context['context_path']],
'#post_render' => [function() {}],
];
$this->renderer->expects($this->once())
->method('renderPlain')
->with($build)
->willReturn($context['context_path']);
$result = $field->advancedRender($row);
$this->assertEquals($link_html, $result);
}
/**
* Data provider for ::testRenderAsExternalLinkWithPathAndTokens().
*
* @return array
* Test data.
*/
public function providerTestRenderAsExternalLinkWithPathAndTokens() {
$data = [];
$data[] = ['{{ foo }}', ['{{ foo }}' => 'http://www.drupal.org'], '<a href="http://www.drupal.org">value</a>', ['context_path' => 'http://www.drupal.org']];
$data[] = ['{{ foo }}', ['{{ foo }}' => ''], 'value', ['context_path' => '']];
$data[] = ['{{ foo }}', ['{{ foo }}' => ''], 'value', ['context_path' => '', 'alter' => ['external' => TRUE]]];
$data[] = ['{{ foo }}', ['{{ foo }}' => '/test-path/123'], '<a href="/test-path/123">value</a>', ['context_path' => '/test-path/123']];
return $data;
}
/**
* Sets up a test field.
*

View file

@ -7,10 +7,16 @@
namespace Drupal\Tests\views\Unit;
use Drupal\Component\Plugin\PluginManagerInterface;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Url;
use Drupal\Tests\UnitTestCase;
use Drupal\views\Entity\View;
use Drupal\views\Plugin\views\cache\CachePluginBase;
use Drupal\views\Plugin\views\cache\None as NoneCache;
use Drupal\views\Plugin\views\pager\None as NonePager;
use Drupal\views\Plugin\views\query\QueryPluginBase;
use Drupal\views\ViewExecutable;
use Symfony\Component\Routing\Route;
@ -76,6 +82,20 @@ class ViewExecutableTest extends UnitTestCase {
*/
protected $routeProvider;
/**
* The mocked none cache plugin.
*
* @var \Drupal\views\Plugin\views\cache\None|\PHPUnit_Framework_MockObject_MockObject
*/
protected $noneCache;
/**
* The mocked cache plugin that returns a successful result.
*
* @var \Drupal\views\Plugin\views\cache\None|\PHPUnit_Framework_MockObject_MockObject
*/
protected $successCache;
/**
* {@inheritdoc}
*/
@ -103,10 +123,26 @@ class ViewExecutableTest extends UnitTestCase {
->disableOriginalConstructor()
->getMock();
$module_handler = $this->getMockBuilder(ModuleHandlerInterface::class)
->getMock();
$this->noneCache = $this->getMockBuilder(NoneCache::class)
->disableOriginalConstructor()
->getMock();
$success_cache = $this->prophesize(CachePluginBase::class);
$success_cache->cacheGet('results')->willReturn(TRUE);
$this->successCache = $success_cache->reveal();
$cache_manager = $this->prophesize(PluginManagerInterface::class);
$cache_manager->createInstance('none')->willReturn($this->noneCache);
$translation = $this->getStringTranslationStub();
$container = new ContainerBuilder();
$container->set('string_translation', $translation);
$container->set('views.executable', $this->viewExecutableFactory);
$container->set('module_handler', $module_handler);
$container->set('plugin.manager.views.cache', $cache_manager->reveal());
\Drupal::setContainer($container);
}
@ -452,6 +488,11 @@ class ViewExecutableTest extends UnitTestCase {
$display = $this->getMockBuilder('Drupal\views\Plugin\views\display\DisplayPluginBase')
->disableOriginalConstructor()
->getMock();
$display->expects($this->any())
->method('getPlugin')
->with($this->equalTo('cache'))
->willReturn($this->successCache);
$display->display = $config['display']['default'];
$view->current_display = 'default';
@ -466,6 +507,10 @@ class ViewExecutableTest extends UnitTestCase {
->with('default')
->willReturn(TRUE);
foreach (array_keys($view->getHandlerTypes()) as $type) {
$view->$type = [];
}
return array($view, $display);
}
@ -565,4 +610,31 @@ class ViewExecutableTest extends UnitTestCase {
$this->assertNotContains('page:12', $view->element['#cache']['keys']);
}
/**
* @covers ::execute
*/
public function testCacheIsIgnoredDuringPreview() {
/** @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();
// 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;
$view->live_preview = TRUE;
$this->noneCache->expects($this->once())->method('cacheGet');
$query->expects($this->once())->method('execute');
$view->execute();
}
}