Update to Drupal 8.0.5. For more information, see https://www.drupal.org/node/2679347
This commit is contained in:
parent
2a9f1f148d
commit
fd3b12cf27
251 changed files with 5439 additions and 957 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\KernelTests\Core\Theme\ThemeRenderAndAutoescapeTest.
|
||||
* Contains \Drupal\KernelTests\Core\Theme\TwigMarkupInterfaceTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\KernelTests\Core\Theme;
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\Component\Diff\Engine\DiffEngineTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\Component\Diff\Engine;
|
||||
|
||||
use Drupal\Component\Diff\Engine\DiffEngine;
|
||||
use Drupal\Component\Diff\Engine\DiffOpAdd;
|
||||
use Drupal\Component\Diff\Engine\DiffOpCopy;
|
||||
use Drupal\Component\Diff\Engine\DiffOpChange;
|
||||
use Drupal\Component\Diff\Engine\DiffOpDelete;
|
||||
|
||||
/**
|
||||
* Test DiffEngine class.
|
||||
*
|
||||
* @coversDefaultClass \Drupal\Component\Diff\Engine\DiffEngine
|
||||
*
|
||||
* @group Diff
|
||||
*/
|
||||
class DiffEngineTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* - Expected output in terms of return class. A list of class names
|
||||
* expected to be returned by DiffEngine::diff().
|
||||
* - An array of strings to change from.
|
||||
* - An array of strings to change to.
|
||||
*/
|
||||
public function provideTestDiff() {
|
||||
return [
|
||||
'empty' => [[], [], []],
|
||||
'add' => [[DiffOpAdd::class], [], ['a']],
|
||||
'copy' => [[DiffOpCopy::class], ['a'], ['a']],
|
||||
'change' => [[DiffOpChange::class], ['a'], ['b']],
|
||||
'copy-and-change' => [
|
||||
[
|
||||
DiffOpCopy::class,
|
||||
DiffOpChange::class,
|
||||
],
|
||||
['a', 'b'],
|
||||
['a', 'c'],
|
||||
],
|
||||
'copy-change-copy' => [
|
||||
[
|
||||
DiffOpCopy::class,
|
||||
DiffOpChange::class,
|
||||
DiffOpCopy::class,
|
||||
],
|
||||
['a', 'b', 'd'],
|
||||
['a', 'c', 'd'],
|
||||
],
|
||||
'copy-change-copy-add' => [
|
||||
[
|
||||
DiffOpCopy::class,
|
||||
DiffOpChange::class,
|
||||
DiffOpCopy::class,
|
||||
DiffOpAdd::class,
|
||||
],
|
||||
['a', 'b', 'd'],
|
||||
['a', 'c', 'd', 'e'],
|
||||
],
|
||||
'copy-delete' => [
|
||||
[
|
||||
DiffOpCopy::class,
|
||||
DiffOpDelete::class,
|
||||
],
|
||||
['a', 'b', 'd'],
|
||||
['a'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether op classes returned by DiffEngine::diff() match expectations.
|
||||
*
|
||||
* @covers ::diff
|
||||
* @dataProvider provideTestDiff
|
||||
*/
|
||||
public function testDiff($expected, $from, $to) {
|
||||
$diff_engine = new DiffEngine();
|
||||
$diff = $diff_engine->diff($from, $to);
|
||||
// Make sure we have the same number of results as expected.
|
||||
$this->assertCount(count($expected), $diff);
|
||||
// Make sure the diff objects match our expectations.
|
||||
foreach ($expected as $index => $op_class) {
|
||||
$this->assertEquals($op_class, get_class($diff[$index]));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
36
core/tests/Drupal/Tests/Component/Diff/Engine/DiffOpTest.php
Normal file
36
core/tests/Drupal/Tests/Component/Diff/Engine/DiffOpTest.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\Component\Diff\Engine\DiffOpTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\Component\Diff\Engine;
|
||||
|
||||
use Drupal\Component\Diff\Engine\DiffOp;
|
||||
|
||||
/**
|
||||
* Test DiffOp base class.
|
||||
*
|
||||
* The only significant behavior here is that ::reverse() should throw an error
|
||||
* if not overridden. In versions of this code in other projects, reverse() is
|
||||
* marked as abstract, which enforces some of this behavior.
|
||||
*
|
||||
* @coversDefaultClass \Drupal\Component\Diff\Engine\DiffOp
|
||||
*
|
||||
* @group Diff
|
||||
*/
|
||||
class DiffOpTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
/**
|
||||
* DiffOp::reverse() always throws an error.
|
||||
*
|
||||
* @covers ::reverse
|
||||
*/
|
||||
public function testReverse() {
|
||||
$this->setExpectedException(\PHPUnit_Framework_Error::class);
|
||||
$op = new DiffOp();
|
||||
$result = $op->reverse();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\Component\Diff\Engine\DiffOpTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\Component\Diff\Engine;
|
||||
|
||||
use Drupal\Component\Diff\Engine\HWLDFWordAccumulator;
|
||||
|
||||
/**
|
||||
* Test HWLDFWordAccumulator.
|
||||
*
|
||||
* @coversDefaultClass \Drupal\Component\Diff\Engine\HWLDFWordAccumulator
|
||||
*
|
||||
* @group Diff
|
||||
*/
|
||||
class HWLDFWordAccumulatorTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
/**
|
||||
* Verify that we only get back a NBSP from an empty accumulator.
|
||||
*
|
||||
* @covers ::getLines
|
||||
*
|
||||
* @see Drupal\Component\Diff\Engine\HWLDFWordAccumulator::NBSP
|
||||
*/
|
||||
public function testGetLinesEmpty() {
|
||||
$acc = new HWLDFWordAccumulator();
|
||||
$this->assertEquals([' '], $acc->getLines());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* - Expected array of lines from getLines().
|
||||
* - Array of strings for the $words parameter to addWords().
|
||||
* - String tag for the $tag parameter to addWords().
|
||||
*/
|
||||
public function provideAddWords() {
|
||||
return [
|
||||
[['wordword2'], ['word', 'word2'], 'tag'],
|
||||
[['word', 'word2'], ['word', "\nword2"], 'tag'],
|
||||
[[' ', 'word2'], ['', "\nword2"], 'tag'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::addWords
|
||||
* @dataProvider provideAddWords
|
||||
*/
|
||||
public function testAddWords($expected, $words, $tag) {
|
||||
$acc = new HWLDFWordAccumulator();
|
||||
$acc->addWords($words, $tag);
|
||||
$this->assertEquals($expected, $acc->getLines());
|
||||
}
|
||||
|
||||
}
|
|
@ -7,8 +7,11 @@
|
|||
|
||||
namespace Drupal\Tests\Core\Config\Entity;
|
||||
|
||||
use Drupal\Component\Plugin\PluginManagerInterface;
|
||||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
use Drupal\Core\Language\Language;
|
||||
use Drupal\Core\Plugin\DefaultLazyPluginCollection;
|
||||
use Drupal\Tests\Core\Config\Entity\Fixtures\ConfigEntityBaseWithPluginCollections;
|
||||
use Drupal\Tests\Core\Plugin\Fixtures\TestConfigurablePlugin;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
|
@ -307,6 +310,36 @@ class ConfigEntityBaseUnitTest extends UnitTestCase {
|
|||
$this->assertEquals(array('test_provider'), $this->entity->calculateDependencies()->getDependencies()['module']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__sleep
|
||||
*/
|
||||
public function testSleepWithPluginCollections() {
|
||||
$instance_id = 'the_instance_id';
|
||||
$instance = new TestConfigurablePlugin([], $instance_id, []);
|
||||
|
||||
$plugin_manager = $this->prophesize(PluginManagerInterface::class);
|
||||
$plugin_manager->createInstance($instance_id, ['id' => $instance_id])->willReturn($instance);
|
||||
|
||||
$entity_values = ['the_plugin_collection_config' => [$instance_id => ['foo' => 'original_value']]];
|
||||
$entity = new TestConfigEntityWithPluginCollections($entity_values, $this->entityTypeId);
|
||||
$entity->setPluginManager($plugin_manager->reveal());
|
||||
|
||||
// After creating the entity, change the plugin configuration.
|
||||
$instance->setConfiguration(['foo' => 'new_value']);
|
||||
|
||||
// After changing the plugin configuration, the entity still has the
|
||||
// original value.
|
||||
$expected_plugin_config = [$instance_id => ['foo' => 'original_value']];
|
||||
$this->assertSame($expected_plugin_config, $entity->get('the_plugin_collection_config'));
|
||||
|
||||
// Ensure the plugin collection is not stored.
|
||||
$this->assertNotContains('pluginCollection', $entity->__sleep());
|
||||
|
||||
$expected_plugin_config = [$instance_id => ['foo' => 'new_value']];
|
||||
// Ensure the updated values are stored in the entity.
|
||||
$this->assertSame($expected_plugin_config, $entity->get('the_plugin_collection_config'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::setOriginalId
|
||||
* @covers ::getOriginalId
|
||||
|
@ -579,3 +612,20 @@ class ConfigEntityBaseUnitTest extends UnitTestCase {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
class TestConfigEntityWithPluginCollections extends ConfigEntityBaseWithPluginCollections {
|
||||
|
||||
protected $pluginCollection;
|
||||
|
||||
public function setPluginManager(PluginManagerInterface $plugin_manager) {
|
||||
$this->pluginCollection = new DefaultLazyPluginCollection($plugin_manager, ['the_instance_id' => ['id' => 'the_instance_id']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPluginCollections() {
|
||||
return ['the_plugin_collection_config' => $this->pluginCollection];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,10 +36,7 @@ class DependencySerializationTest extends UnitTestCase {
|
|||
$dependencySerialization->setContainer($container);
|
||||
|
||||
$string = serialize($dependencySerialization);
|
||||
$object = unserialize($string);
|
||||
|
||||
$string = serialize($dependencySerialization);
|
||||
/** @var \Drupal\Tests\Core\DependencyInjection\DependencySerializationTestDummy $object */
|
||||
/** @var \Drupal\Tests\Core\DependencyInjection\DependencySerializationTestDummy $dependencySerialization */
|
||||
$dependencySerialization = unserialize($string);
|
||||
|
||||
$this->assertSame($service, $dependencySerialization->service);
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\Core\Menu\MenuLinkDefaultFormTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\Core\Menu;
|
||||
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\Core\Form\FormState;
|
||||
use Drupal\Core\Menu\Form\MenuLinkDefaultForm;
|
||||
use Drupal\Core\Menu\MenuLinkDefault;
|
||||
use Drupal\Core\Menu\MenuLinkManagerInterface;
|
||||
use Drupal\Core\Menu\MenuParentFormSelectorInterface;
|
||||
use Drupal\Core\Menu\StaticMenuLinkOverridesInterface;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\Core\Menu\Form\MenuLinkDefaultForm
|
||||
* @group Menu
|
||||
*/
|
||||
class MenuLinkDefaultFormTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* @covers ::extractFormValues
|
||||
*/
|
||||
public function testExtractFormValues() {
|
||||
$menu_link_manager = $this->prophesize(MenuLinkManagerInterface::class);
|
||||
$menu_parent_form_selector = $this->prophesize(MenuParentFormSelectorInterface::class);
|
||||
$module_handler = $this->prophesize(ModuleHandlerInterface::class);
|
||||
$menu_link_form = new MenuLinkDefaultForm($menu_link_manager->reveal(), $menu_parent_form_selector->reveal(), $this->getStringTranslationStub(), $module_handler->reveal());
|
||||
|
||||
$static_override = $this->prophesize(StaticMenuLinkOverridesInterface::class);
|
||||
$menu_link = new MenuLinkDefault([], 'my_plugin_id', [], $static_override->reveal());
|
||||
$menu_link_form->setMenuLinkInstance($menu_link);
|
||||
|
||||
$form_state = new FormState();
|
||||
$form_state->setValue('id', 'my_plugin_id');
|
||||
$form_state->setValue('enabled', FALSE);
|
||||
$form_state->setValue('weight', 5);
|
||||
$form_state->setValue('expanded', TRUE);
|
||||
$form_state->setValue('menu_parent', 'foo:bar');
|
||||
|
||||
$form = [];
|
||||
$result = $menu_link_form->extractFormValues($form, $form_state);
|
||||
|
||||
$this->assertEquals([
|
||||
'id' => 'my_plugin_id',
|
||||
'enabled' => 0,
|
||||
'weight' => 5,
|
||||
'expanded' => 1,
|
||||
'parent' => 'bar',
|
||||
'menu_name' => 'foo'
|
||||
], $result);
|
||||
}
|
||||
|
||||
}
|
|
@ -94,7 +94,7 @@ class ContentTypeHeaderMatcherTest extends UnitTestCase {
|
|||
* Confirms that the matcher throws an exception for no-route.
|
||||
*
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\UnsupportedMediaTypeHttpException
|
||||
* @expectedExceptionMessage No route found that matches the Content-Type header.
|
||||
* @expectedExceptionMessage No route found that matches "Content-Type: application/hal+json"
|
||||
*/
|
||||
public function testNoRouteFound() {
|
||||
$matcher = new ContentTypeHeaderMatcher();
|
||||
|
|
|
@ -9,12 +9,15 @@ namespace Drupal\Tests\Core\Routing;
|
|||
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
use Drupal\Core\PathProcessor\OutboundPathProcessorInterface;
|
||||
use Drupal\Core\PathProcessor\PathProcessorAlias;
|
||||
use Drupal\Core\PathProcessor\PathProcessorManager;
|
||||
use Drupal\Core\Render\BubbleableMetadata;
|
||||
use Drupal\Core\Routing\RequestContext;
|
||||
use Drupal\Core\Routing\RouteProviderInterface;
|
||||
use Drupal\Core\Routing\UrlGenerator;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Prophecy\Argument;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\Routing\Route;
|
||||
|
@ -28,6 +31,13 @@ use Symfony\Component\Routing\RouteCollection;
|
|||
*/
|
||||
class UrlGeneratorTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* The route provider.
|
||||
*
|
||||
* @var \Drupal\Core\Routing\RouteProviderInterface
|
||||
*/
|
||||
protected $provider;
|
||||
|
||||
/**
|
||||
* The url generator to test.
|
||||
*
|
||||
|
@ -56,6 +66,13 @@ class UrlGeneratorTest extends UnitTestCase {
|
|||
*/
|
||||
protected $requestStack;
|
||||
|
||||
/**
|
||||
* The request context.
|
||||
*
|
||||
* @var \Drupal\Core\Routing\RequestContext
|
||||
*/
|
||||
protected $context;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -115,7 +132,8 @@ class UrlGeneratorTest extends UnitTestCase {
|
|||
$route_name_return_map[] = array($values['route_name'], $values['return']);
|
||||
$routes_names_return_map[] = array(array($values['route_name']), $values['return']);
|
||||
}
|
||||
$provider->expects($this->any())
|
||||
$this->provider = $provider;
|
||||
$this->provider->expects($this->any())
|
||||
->method('getRouteByName')
|
||||
->will($this->returnValueMap($route_name_return_map));
|
||||
$provider->expects($this->any())
|
||||
|
@ -137,8 +155,8 @@ class UrlGeneratorTest extends UnitTestCase {
|
|||
$request = Request::create('/some/path');
|
||||
$this->requestStack->push($request);
|
||||
|
||||
$context = new RequestContext();
|
||||
$context->fromRequestStack($this->requestStack);
|
||||
$this->context = new RequestContext();
|
||||
$this->context->fromRequestStack($this->requestStack);
|
||||
|
||||
$processor = new PathProcessorAlias($this->aliasManager);
|
||||
$processor_manager = new PathProcessorManager();
|
||||
|
@ -148,8 +166,8 @@ class UrlGeneratorTest extends UnitTestCase {
|
|||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$generator = new UrlGenerator($provider, $processor_manager, $this->routeProcessorManager, $this->requestStack, ['http', 'https']);
|
||||
$generator->setContext($context);
|
||||
$generator = new UrlGenerator($this->provider, $processor_manager, $this->routeProcessorManager, $this->requestStack, ['http', 'https']);
|
||||
$generator->setContext($this->context);
|
||||
$this->generator = $generator;
|
||||
}
|
||||
|
||||
|
@ -198,6 +216,54 @@ class UrlGeneratorTest extends UnitTestCase {
|
|||
$this->assertEquals('test/one', $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::generateFromRoute
|
||||
*/
|
||||
public function testUrlGenerationWithDisabledPathProcessing() {
|
||||
$path_processor = $this->prophesize(OutboundPathProcessorInterface::class);
|
||||
$path_processor->processOutbound(Argument::cetera())->shouldNotBeCalled();
|
||||
|
||||
$generator = new UrlGenerator($this->provider, $path_processor->reveal(), $this->routeProcessorManager, $this->requestStack, ['http', 'https']);
|
||||
$generator->setContext($this->context);
|
||||
|
||||
$url = $this->generator->generateFromRoute('test_1', [], ['path_processing' => FALSE]);
|
||||
$this->assertEquals('/test/one', $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::generateFromRoute
|
||||
*/
|
||||
public function testUrlGenerationWithDisabledPathProcessingByRoute() {
|
||||
$path_processor = $this->prophesize(OutboundPathProcessorInterface::class);
|
||||
$path_processor->processOutbound(Argument::cetera())->shouldNotBeCalled();
|
||||
|
||||
$provider = $this->prophesize(RouteProviderInterface::class);
|
||||
$provider->getRouteByName('test_1')->willReturn(new Route('/test/one', [], [], ['default_url_options' => ['path_processing' => FALSE]]));
|
||||
|
||||
$generator = new UrlGenerator($provider->reveal(), $path_processor->reveal(), $this->routeProcessorManager, $this->requestStack, ['http', 'https']);
|
||||
$generator->setContext($this->context);
|
||||
|
||||
$url = $generator->generateFromRoute('test_1', []);
|
||||
$this->assertEquals('/test/one', $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::generateFromRoute
|
||||
*/
|
||||
public function testUrlGenerationWithDisabledPathProcessingByRouteAndOptedInPathProcessing() {
|
||||
$path_processor = $this->prophesize(OutboundPathProcessorInterface::class);
|
||||
$path_processor->processOutbound('/test/one', Argument::cetera())->willReturn('/hello/world')->shouldBeCalled();
|
||||
|
||||
$provider = $this->prophesize(RouteProviderInterface::class);
|
||||
$provider->getRouteByName('test_1')->willReturn(new Route('/test/one', [], [], ['default_url_options' => ['path_processing' => FALSE]]));
|
||||
|
||||
$generator = new UrlGenerator($provider->reveal(), $path_processor->reveal(), $this->routeProcessorManager, $this->requestStack, ['http', 'https']);
|
||||
$generator->setContext($this->context);
|
||||
|
||||
$url = $generator->generateFromRoute('test_1', [], ['path_processing' => TRUE]);
|
||||
$this->assertEquals('/hello/world', $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests URL generation in a subdirectory.
|
||||
*/
|
||||
|
|
|
@ -86,8 +86,7 @@ class RegistryTest extends UnitTestCase {
|
|||
* Tests getting the theme registry defined by a module.
|
||||
*/
|
||||
public function testGetRegistryForModule() {
|
||||
$this->setupTheme('test_theme');
|
||||
$this->registry->setTheme(new ActiveTheme([
|
||||
$test_theme = new ActiveTheme([
|
||||
'name' => 'test_theme',
|
||||
'path' => 'core/modules/system/tests/themes/test_theme/test_theme.info.yml',
|
||||
'engine' => 'twig',
|
||||
|
@ -98,11 +97,29 @@ class RegistryTest extends UnitTestCase {
|
|||
'libraries' => [],
|
||||
'extension' => '.twig',
|
||||
'base_themes' => [],
|
||||
]));
|
||||
]);
|
||||
|
||||
// Include the module so that hook_theme can be called.
|
||||
$test_stable = new ActiveTheme([
|
||||
'name' => 'test_stable',
|
||||
'path' => 'core/modules/system/tests/themes/test_stable/test_stable.info.yml',
|
||||
'engine' => 'twig',
|
||||
'owner' => 'twig',
|
||||
'stylesheets_remove' => [],
|
||||
'libraries_override' => [],
|
||||
'libraries_extend' => [],
|
||||
'libraries' => [],
|
||||
'extension' => '.twig',
|
||||
'base_themes' => [],
|
||||
]);
|
||||
|
||||
$this->themeManager->expects($this->exactly(2))
|
||||
->method('getActiveTheme')
|
||||
->willReturnOnConsecutiveCalls($test_theme, $test_stable);
|
||||
|
||||
// Include the module and theme files so that hook_theme can be called.
|
||||
include_once $this->root . '/core/modules/system/tests/modules/theme_test/theme_test.module';
|
||||
$this->moduleHandler->expects($this->once())
|
||||
include_once $this->root . '/core/modules/system/tests/themes/test_stable/test_stable.theme';
|
||||
$this->moduleHandler->expects($this->exactly(2))
|
||||
->method('getImplementations')
|
||||
->with('theme')
|
||||
->will($this->returnValue(array('theme_test')));
|
||||
|
@ -126,16 +143,24 @@ class RegistryTest extends UnitTestCase {
|
|||
$this->assertArrayHasKey('theme_test_function_template_override', $registry);
|
||||
|
||||
$this->assertArrayNotHasKey('test_theme_not_existing_function', $registry);
|
||||
$this->assertFalse(in_array('test_stable_preprocess_theme_test_render_element', $registry['theme_test_render_element']['preprocess functions']));
|
||||
|
||||
$info = $registry['theme_test_function_suggestions'];
|
||||
$this->assertEquals('module', $info['type']);
|
||||
$this->assertEquals('core/modules/system/tests/modules/theme_test', $info['theme path']);
|
||||
$this->assertEquals('theme_theme_test_function_suggestions', $info['function']);
|
||||
$this->assertEquals(array(), $info['variables']);
|
||||
|
||||
// The second call will initialize with the second theme. Ensure that this
|
||||
// returns a different object and the discovery for the second theme's
|
||||
// preprocess function worked.
|
||||
$other_registry = $this->registry->get();
|
||||
$this->assertNotSame($registry, $other_registry);
|
||||
$this->assertTrue(in_array('test_stable_preprocess_theme_test_render_element', $other_registry['theme_test_render_element']['preprocess functions']));
|
||||
}
|
||||
|
||||
protected function setupTheme($theme_name = NULL) {
|
||||
$this->registry = new TestRegistry($this->root, $this->cache, $this->lock, $this->moduleHandler, $this->themeHandler, $this->themeInitialization, $theme_name);
|
||||
protected function setupTheme() {
|
||||
$this->registry = new TestRegistry($this->root, $this->cache, $this->lock, $this->moduleHandler, $this->themeHandler, $this->themeInitialization);
|
||||
$this->registry->setThemeManager($this->themeManager);
|
||||
}
|
||||
|
||||
|
@ -143,23 +168,10 @@ class RegistryTest extends UnitTestCase {
|
|||
|
||||
class TestRegistry extends Registry {
|
||||
|
||||
public function setTheme(ActiveTheme $theme) {
|
||||
$this->theme = $theme;
|
||||
}
|
||||
|
||||
protected function init($theme_name = NULL) {
|
||||
}
|
||||
|
||||
protected function getPath($module) {
|
||||
if ($module == 'theme_test') {
|
||||
return 'core/modules/system/tests/modules/theme_test';
|
||||
}
|
||||
}
|
||||
|
||||
protected function listThemes() {
|
||||
}
|
||||
|
||||
protected function initializeTheme() {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
38
core/tests/Drupal/Tests/Core/TypedData/TypedDataTest.php
Normal file
38
core/tests/Drupal/Tests/Core/TypedData/TypedDataTest.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\Core\TypedData\TypedDataTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\Core\TypedData;
|
||||
|
||||
use Drupal\Core\TypedData\DataDefinitionInterface;
|
||||
use Drupal\Core\TypedData\TypedData;
|
||||
use Drupal\Core\TypedData\TypedDataManagerInterface;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\Core\TypedData\TypedData
|
||||
*
|
||||
* @group TypedData
|
||||
*/
|
||||
class TypedDataTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* @covers ::__sleep
|
||||
*/
|
||||
public function testSleep() {
|
||||
$data_definition = $this->getMock(DataDefinitionInterface::class);
|
||||
/** @var \Drupal\Core\TypedData\TypedData $typed_data */
|
||||
$typed_data = $this->getMockForAbstractClass(TypedData::class, [$data_definition]);
|
||||
$string_translation = $this->getStringTranslationStub();
|
||||
$typed_data->setStringTranslation($string_translation);
|
||||
$typed_data_manager = $this->getMock(TypedDataManagerInterface::class);
|
||||
$typed_data->setTypedDataManager($typed_data_manager);
|
||||
$serialized_typed_data = serialize($typed_data);
|
||||
$this->assertNotContains(get_class($string_translation), $serialized_typed_data);
|
||||
$this->assertNotContains(get_class($typed_data_manager), $serialized_typed_data);
|
||||
}
|
||||
|
||||
}
|
|
@ -89,28 +89,28 @@ class ErrorTest extends UnitTestCase {
|
|||
$data = array();
|
||||
|
||||
// Test with no function, main should be in the backtrace.
|
||||
$data[] = array(array($this->createBacktraceItem(NULL, NULL)), "main()\n");
|
||||
$data[] = array(array($this->createBacktraceItem(NULL, NULL)), "main() (Line: 10)\n");
|
||||
|
||||
$base = array($this->createBacktraceItem());
|
||||
$data[] = array($base, "test_function()\n");
|
||||
$data[] = array($base, "test_function() (Line: 10)\n");
|
||||
|
||||
// Add a second item.
|
||||
$second_item = $base;
|
||||
$second_item[] = $this->createBacktraceItem('test_function_2');
|
||||
|
||||
$data[] = array($second_item, "test_function()\ntest_function_2()\n");
|
||||
$data[] = array($second_item, "test_function() (Line: 10)\ntest_function_2() (Line: 10)\n");
|
||||
|
||||
// Add a second item, with a class.
|
||||
$second_item_class = $base;
|
||||
$second_item_class[] = $this->createBacktraceItem('test_function_2', 'TestClass');
|
||||
|
||||
$data[] = array($second_item_class, "test_function()\nTestClass->test_function_2()\n");
|
||||
$data[] = array($second_item_class, "test_function() (Line: 10)\nTestClass->test_function_2() (Line: 10)\n");
|
||||
|
||||
// Add a second item, with a class.
|
||||
$second_item_args = $base;
|
||||
$second_item_args[] = $this->createBacktraceItem('test_function_2', NULL, array('string', 10, new \stdClass()));
|
||||
|
||||
$data[] = array($second_item_args, "test_function()\ntest_function_2('string', 10, Object)\n");
|
||||
$data[] = array($second_item_args, "test_function() (Line: 10)\ntest_function_2('string', 10, Object) (Line: 10)\n");
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
@ -124,14 +124,16 @@ class ErrorTest extends UnitTestCase {
|
|||
* (optional) The class to use in the backtrace item.
|
||||
* @param array $args
|
||||
* (optional) An array of function arguments to add to the backtrace item.
|
||||
* @param int $line
|
||||
* (optional) The line where the function was called.
|
||||
*
|
||||
* @return array
|
||||
* A backtrace array item.
|
||||
*/
|
||||
protected function createBacktraceItem($function = 'test_function', $class = NULL, array $args = array()) {
|
||||
protected function createBacktraceItem($function = 'test_function', $class = NULL, array $args = array(), $line = 10) {
|
||||
$backtrace = array(
|
||||
'file' => 'test_file',
|
||||
'line' => 10,
|
||||
'line' => $line,
|
||||
'function' => $function,
|
||||
'args' => array(),
|
||||
);
|
||||
|
|
Reference in a new issue