Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663
This commit is contained in:
parent
eb34d130a8
commit
f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions
|
@ -97,6 +97,7 @@ class ViewAjaxControllerTest extends UnitTestCase {
|
|||
$this->getMock('\Drupal\Core\Controller\ControllerResolverInterface'),
|
||||
$this->getMock('\Drupal\Core\Theme\ThemeManagerInterface'),
|
||||
$element_info_manager,
|
||||
$this->getMock('\Drupal\Core\Render\PlaceholderGeneratorInterface'),
|
||||
$this->getMock('\Drupal\Core\Render\RenderCacheInterface'),
|
||||
$request_stack,
|
||||
[
|
||||
|
|
|
@ -485,7 +485,7 @@ class EntityViewsDataTest extends UnitTestCase {
|
|||
$base_field_definitions = $this->setupBaseFields(EntityTestMul::baseFieldDefinitions($this->baseEntityType));
|
||||
$base_field_definitions['type'] = BaseFieldDefinition::create('entity_reference')
|
||||
->setLabel('entity test type')
|
||||
->setSettings(array('target_type' => 'entity_test_bundle'))
|
||||
->setSetting('target_type', 'entity_test_bundle')
|
||||
->setTranslatable(TRUE);
|
||||
$base_field_definitions = $this->setupBaseFields($base_field_definitions);
|
||||
$user_base_field_definitions = [
|
||||
|
|
|
@ -64,7 +64,7 @@ class RouteSubscriberTest extends UnitTestCase {
|
|||
* @covers ::routeRebuildFinished
|
||||
*/
|
||||
public function testRouteRebuildFinished() {
|
||||
list($view, $executable, $display_1, $display_2) = $this->setupMocks();
|
||||
list($display_1, $display_2) = $this->setupMocks();
|
||||
|
||||
$display_1->expects($this->once())
|
||||
->method('collectRoutes')
|
||||
|
@ -95,7 +95,7 @@ class RouteSubscriberTest extends UnitTestCase {
|
|||
|
||||
$route_event = new RouteBuildEvent($collection, 'views');
|
||||
|
||||
list($view, $executable, $display_1, $display_2) = $this->setupMocks();
|
||||
list($display_1, $display_2) = $this->setupMocks();
|
||||
|
||||
// The page_1 display overrides an existing route, so the dynamicRoutes
|
||||
// should only call the second display.
|
||||
|
@ -139,9 +139,8 @@ class RouteSubscriberTest extends UnitTestCase {
|
|||
/**
|
||||
* Sets up mocks of Views objects needed for testing.
|
||||
*
|
||||
* @return array
|
||||
* An array of Views mocks, including the executable, the view entity, and
|
||||
* two display plugins.
|
||||
* @return array \Drupal\views\Plugin\views\display\DisplayRouterInterface[]|\PHPUnit_Framework_MockObject_MockObject[]
|
||||
* An array of two mocked view displays
|
||||
*/
|
||||
protected function setupMocks() {
|
||||
$executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
|
||||
|
@ -190,7 +189,7 @@ class RouteSubscriberTest extends UnitTestCase {
|
|||
$this->routeSubscriber->applicableViews[] = array('test_id', 'page_2');
|
||||
$this->routeSubscriber->applicableViews[] = array('test_id', 'page_3');
|
||||
|
||||
return array($executable, $view, $display_1, $display_2);
|
||||
return array($display_1, $display_2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -206,7 +206,8 @@ class ViewsBlockTest extends UnitTestCase {
|
|||
}
|
||||
|
||||
namespace {
|
||||
// @todo replace views_add_contextual_links()
|
||||
// @todo https://www.drupal.org/node/2571679 replace
|
||||
// views_add_contextual_links().
|
||||
if (!function_exists('views_add_contextual_links')) {
|
||||
function views_add_contextual_links() {
|
||||
}
|
||||
|
|
|
@ -130,10 +130,10 @@ class EntityTest extends UnitTestCase {
|
|||
*/
|
||||
public function providerTestTokens() {
|
||||
return [
|
||||
['!1', 5],
|
||||
['%2', 6],
|
||||
['{{ raw_arguments.test1 }}', 5],
|
||||
['{{ arguments.test2 }}', 6],
|
||||
['{{ test_render_token }}', 7],
|
||||
['[test:global_token]', 8],
|
||||
['{{ test:global_token }}', 8],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -5,9 +5,12 @@
|
|||
* Contains \Drupal\Tests\views\Unit\Plugin\field\FieldPluginBaseTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\views\Unit\Plugin\field;
|
||||
namespace Drupal\Tests\views\Unit\Plugin\field {
|
||||
|
||||
use Drupal\Core\GeneratedUrl;
|
||||
use Drupal\Core\Language\Language;
|
||||
use Drupal\Core\Render\RendererInterface;
|
||||
use Drupal\Core\Render\Markup;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\Core\Utility\LinkGenerator;
|
||||
use Drupal\Core\Utility\LinkGeneratorInterface;
|
||||
|
@ -174,6 +177,22 @@ class FieldPluginBaseTest extends UnitTestCase {
|
|||
\Drupal::getContainer()->set('unrouted_url_assembler', $this->unroutedUrlAssembler);
|
||||
|
||||
$this->linkGenerator = new LinkGenerator($this->urlGenerator, $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface'), $this->renderer);
|
||||
$this->renderer
|
||||
->method('render')
|
||||
->willReturnCallback(
|
||||
// Pretend to do a render.
|
||||
function (&$elements, $is_root_call = FALSE) {
|
||||
// Mock the ability to theme links
|
||||
$link = $this->linkGenerator->generate($elements['#title'], $elements['#url']);
|
||||
if (isset($elements['#prefix'])) {
|
||||
$link = $elements['#prefix'] . $link;
|
||||
}
|
||||
if (isset($elements['#suffix'])) {
|
||||
$link = $link . $elements['#suffix'];
|
||||
}
|
||||
return Markup::create($link);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -208,6 +227,38 @@ class FieldPluginBaseTest extends UnitTestCase {
|
|||
$this->assertEquals($expected_result, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test rendering as a link without a path.
|
||||
*
|
||||
* @covers ::renderText
|
||||
*/
|
||||
public function testRenderTrimmedWithMoreLink() {
|
||||
$alter = [
|
||||
'trim' => TRUE,
|
||||
'max_length' => 7,
|
||||
'more_link' => TRUE,
|
||||
// Don't invoke translation.
|
||||
'ellipsis' => FALSE,
|
||||
'more_link_text' => 'more link',
|
||||
];
|
||||
|
||||
$this->display->expects($this->any())
|
||||
->method('getHandlers')
|
||||
->willReturnMap([
|
||||
['argument', []],
|
||||
['field', []],
|
||||
]);
|
||||
|
||||
$this->setUpUrlIntegrationServices();
|
||||
$field = $this->setupTestField(['alter' => $alter]);
|
||||
$field->field_alias = 'key';
|
||||
$row = new ResultRow(['key' => 'a long value']);
|
||||
|
||||
$expected_result = 'a long <a href="/%3Cfront%3E" class="views-more-link">more link</a>';
|
||||
$result = $field->advancedRender($row);
|
||||
$this->assertEquals($expected_result, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test rendering of a link with a path and options.
|
||||
*
|
||||
|
@ -229,7 +280,7 @@ class FieldPluginBaseTest extends UnitTestCase {
|
|||
$row = new ResultRow(['key' => 'value']);
|
||||
|
||||
$result = $field->advancedRender($row);
|
||||
$this->assertEquals($final_html, $result);
|
||||
$this->assertEquals($final_html, (string) $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -308,8 +359,8 @@ class FieldPluginBaseTest extends UnitTestCase {
|
|||
|
||||
$this->urlGenerator->expects($this->once())
|
||||
->method('generateFromRoute')
|
||||
->with($expected_url->getRouteName(), $expected_url->getRouteParameters(), $expected_url_options)
|
||||
->willReturn($url_path);
|
||||
->with($expected_url->getRouteName(), $expected_url->getRouteParameters(), $expected_url_options, TRUE)
|
||||
->willReturn((new GeneratedUrl())->setGeneratedUrl($url_path));
|
||||
|
||||
$result = $field->advancedRender($row);
|
||||
$this->assertEquals($final_html, $result);
|
||||
|
@ -449,8 +500,8 @@ class FieldPluginBaseTest extends UnitTestCase {
|
|||
];
|
||||
|
||||
$this->renderer->expects($this->once())
|
||||
->method('render')
|
||||
->with($build, FALSE)
|
||||
->method('renderPlain')
|
||||
->with($build)
|
||||
->willReturn('base:test-path/123');
|
||||
|
||||
$result = $field->advancedRender($row);
|
||||
|
@ -497,6 +548,67 @@ class FieldPluginBaseTest extends UnitTestCase {
|
|||
return $field;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getRenderTokens
|
||||
*/
|
||||
public function testGetRenderTokensWithoutFieldsAndArguments() {
|
||||
$field = $this->setupTestField();
|
||||
|
||||
$this->display->expects($this->any())
|
||||
->method('getHandlers')
|
||||
->willReturnMap([
|
||||
['argument', []],
|
||||
['field', []],
|
||||
]);
|
||||
|
||||
$this->assertEquals([], $field->getRenderTokens([]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getRenderTokens
|
||||
*/
|
||||
public function testGetRenderTokensWithoutArguments() {
|
||||
$field = $this->setupTestField(['id' => 'id']);
|
||||
|
||||
$field->last_render = 'last rendered output';
|
||||
$this->display->expects($this->any())
|
||||
->method('getHandlers')
|
||||
->willReturnMap([
|
||||
['argument', []],
|
||||
['field', ['id' => $field]],
|
||||
]);
|
||||
|
||||
$this->assertEquals(['{{ id }}' => 'last rendered output'], $field->getRenderTokens([]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getRenderTokens
|
||||
*/
|
||||
public function testGetRenderTokensWithArguments() {
|
||||
$field = $this->setupTestField(['id' => 'id']);
|
||||
$field->view->args = ['argument value'];
|
||||
$field->view->build_info['substitutions']['{{ arguments.name }}'] = 'argument value';
|
||||
|
||||
$argument = $this->getMockBuilder('\Drupal\views\Plugin\views\argument\ArgumentPluginBase')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$field->last_render = 'last rendered output';
|
||||
$this->display->expects($this->any())
|
||||
->method('getHandlers')
|
||||
->willReturnMap([
|
||||
['argument', ['name' => $argument]],
|
||||
['field', ['id' => $field]],
|
||||
]);
|
||||
|
||||
$expected = [
|
||||
'{{ id }}' => 'last rendered output',
|
||||
'{{ arguments.name }}' => 'argument value',
|
||||
'{{ raw_arguments.name }}' => 'argument value',
|
||||
];
|
||||
$this->assertEquals($expected, $field->getRenderTokens([]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class FieldPluginBaseTestField extends FieldPluginBase {
|
||||
|
@ -506,3 +618,12 @@ class FieldPluginBaseTestField extends FieldPluginBase {
|
|||
}
|
||||
|
||||
}
|
||||
}
|
||||
// @todo Remove as part of https://www.drupal.org/node/2529170.
|
||||
namespace {
|
||||
if (!function_exists('base_path')) {
|
||||
function base_path() {
|
||||
return '/';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,13 @@ class EntityOperationsUnitTest extends UnitTestCase {
|
|||
*/
|
||||
protected $entityManager;
|
||||
|
||||
/**
|
||||
* The language manager.
|
||||
*
|
||||
* @var \Drupal\Core\Language\LanguageManagerInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
protected $languageManager;
|
||||
|
||||
/**
|
||||
* The plugin under test.
|
||||
*
|
||||
|
@ -38,13 +45,14 @@ class EntityOperationsUnitTest extends UnitTestCase {
|
|||
*/
|
||||
public function setUp() {
|
||||
$this->entityManager = $this->getMock('\Drupal\Core\Entity\EntityManagerInterface');
|
||||
$this->languageManager = $this->getMock('\Drupal\Core\Language\LanguageManagerInterface');
|
||||
|
||||
$configuration = array();
|
||||
$plugin_id = $this->randomMachineName();
|
||||
$plugin_definition = array(
|
||||
'title' => $this->randomMachineName(),
|
||||
);
|
||||
$this->plugin = new EntityOperations($configuration, $plugin_id, $plugin_definition, $this->entityManager);
|
||||
$this->plugin = new EntityOperations($configuration, $plugin_id, $plugin_definition, $this->entityManager, $this->languageManager);
|
||||
|
||||
$redirect_service = $this->getMock('Drupal\Core\Routing\RedirectDestinationInterface');
|
||||
$redirect_service->expects($this->any())
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Contains \Drupal\Tests\views\Unit\Routing\ViewPageControllerTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\views\Unit\Routing;
|
||||
namespace Drupal\Tests\views\Unit\Routing {
|
||||
|
||||
use Drupal\Core\Routing\RouteMatch;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
@ -181,3 +181,14 @@ class ViewPageControllerTest extends UnitTestCase {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace {
|
||||
// @todo https://www.drupal.org/node/2571679 replace
|
||||
// views_add_contextual_links()
|
||||
if (!function_exists('views_add_contextual_links')) {
|
||||
function views_add_contextual_links() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue