Update to Drupal 8.0-dev-2015-11-17. Commits through da81cd220, Tue Nov 17 15:53:49 2015 +0000, Issue #2617224 by Wim Leers: Move around/fix some documentation.

This commit is contained in:
Pantheon Automation 2015-11-17 13:42:33 -08:00 committed by Greg Anderson
parent 4afb23bbd3
commit 7784f4c23d
929 changed files with 19798 additions and 5304 deletions

View file

@ -0,0 +1,79 @@
<?php
/**
* @file \Drupal\KernelTests\Core\Cache\CacheCollectorTest.
*/
namespace Drupal\KernelTests\Core\Cache;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\KernelTests\KernelTestBase;
use Drupal\Tests\Core\Cache\CacheCollectorHelper;
use Symfony\Component\DependencyInjection\Reference;
/**
* Tests DatabaseBackend cache tag implementation.
*
* @group Cache
*/
class CacheCollectorTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['system'];
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
$this->installSchema('system', ['semaphore']);
}
/**
* {@inheritdoc}
*/
public function register(ContainerBuilder $container) {
parent::register($container);
// Change container to database cache backends.
$container
->register('cache_factory', 'Drupal\Core\Cache\CacheFactory')
->addArgument(new Reference('settings'))
->addMethodCall('setContainer', [new Reference('service_container')]);
// Change container to use database lock backends.
$container
->register('lock', 'Drupal\Core\Lock\DatabaseLockBackend')
->addArgument(new Reference('database'));
}
/**
* Tests setting and invalidating
*
* @dataProvider providerTestInvalidCharacters
*/
public function testCacheCollector($cid, $key, $value) {
$collector = new CacheCollectorHelper($cid, $this->container->get('cache.default'), $this->container->get('lock'));
$this->assertNull($collector->get($key));
$collector->set($key, $value);
$this->assertEquals($value, $collector->get($key));
$collector->destruct();
// @todo Shouldn't this be empty after destruction?
$this->assertEquals($value, $collector->get($key));
}
/**
* Data provider for ::testCacheCollector().
*/
public function providerTestInvalidCharacters() {
return [
// Nothing special.
['foo', 'bar', 'baz'],
// Invalid characters in CID.
['éøïвβ中國書۞', 'foo', 'bar'],
// Really long CID.
[$this->randomString(1024), 'foo', 'bar'],
];
}
}

View file

@ -0,0 +1,86 @@
<?php
/**
* @file
* Contains \Drupal\KernelTests\Core\Path\AliasStorageTest.
*/
namespace Drupal\KernelTests\Core\Path;
use Drupal\Core\Language\LanguageInterface;
use Drupal\KernelTests\KernelTestBase;
/**
* @coversDefaultClass \Drupal\Core\Path\AliasStorage
* @group path
*/
class AliasStorageTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['system'];
/** @var \Drupal\Core\Path\AliasStorage */
protected $storage;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installSchema('system', 'url_alias');
$this->storage = $this->container->get('path.alias_storage');
}
/**
* @covers ::load
*/
public function testLoad() {
$this->storage->save('/test-source-Case', '/test-alias-Case');
$expected = [
'pid' => 1,
'alias' => '/test-alias-Case',
'source' => '/test-source-Case',
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
];
$this->assertEquals($expected, $this->storage->load(['alias' => '/test-alias-Case']));
$this->assertEquals($expected, $this->storage->load(['alias' => '/test-alias-case']));
$this->assertEquals($expected, $this->storage->load(['source' => '/test-source-Case']));
$this->assertEquals($expected, $this->storage->load(['source' => '/test-source-case']));
}
/**
* @covers ::lookupPathAlias
*/
public function testLookupPathAlias() {
$this->storage->save('/test-source-Case', '/test-alias');
$this->assertEquals('/test-alias', $this->storage->lookupPathAlias('/test-source-Case', LanguageInterface::LANGCODE_NOT_SPECIFIED));
$this->assertEquals('/test-alias', $this->storage->lookupPathAlias('/test-source-case', LanguageInterface::LANGCODE_NOT_SPECIFIED));
}
/**
* @covers ::lookupPathSource
*/
public function testLookupPathSource() {
$this->storage->save('/test-source', '/test-alias-Case');
$this->assertEquals('/test-source', $this->storage->lookupPathSource('/test-alias-Case', LanguageInterface::LANGCODE_NOT_SPECIFIED));
$this->assertEquals('/test-source', $this->storage->lookupPathSource('/test-alias-case', LanguageInterface::LANGCODE_NOT_SPECIFIED));
}
/**
* @covers ::aliasExists
*/
public function testAliasExists() {
$this->storage->save('/test-source-Case', '/test-alias-Case');
$this->assertTrue($this->storage->aliasExists('/test-alias-Case', LanguageInterface::LANGCODE_NOT_SPECIFIED));
$this->assertTrue($this->storage->aliasExists('/test-alias-case', LanguageInterface::LANGCODE_NOT_SPECIFIED));
}
}

View file

@ -0,0 +1,43 @@
<?php
/**
* @file
* Contains \Drupal\KernelTests\Core\Theme\MaintenanceThemeTest.
*/
namespace Drupal\KernelTests\Core\Theme;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests themes and base themes are correctly loaded.
*
* @group Installer
*/
class MaintenanceThemeTest extends KernelTestBase {
/**
* Tests that the maintenance theme initializes the theme and its base themes.
*/
public function testMaintenanceTheme() {
$this->setSetting('maintenance_theme', 'seven');
// Get the maintenance theme loaded.
drupal_maintenance_theme();
// Do we have an active theme?
$this->assertTrue(\Drupal::theme()->hasActiveTheme());
$active_theme = \Drupal::theme()->getActiveTheme();
$this->assertEquals('seven', $active_theme->getName());
$base_themes = $active_theme->getBaseThemes();
$base_theme_names = array_keys($base_themes);
$this->assertSame(['classy', 'stable'], $base_theme_names);
// Ensure Classy has the correct base themes and amount of base themes.
$classy_base_themes = $base_themes['classy']->getBaseThemes();
$classy_base_theme_names = array_keys($classy_base_themes);
$this->assertSame(['stable'], $classy_base_theme_names);
}
}

View file

@ -0,0 +1,108 @@
<?php
/**
* @file
* Contains \Drupal\KernelTests\Core\Theme\StableTemplateOverrideTest.
*/
namespace Drupal\KernelTests\Core\Theme;
use Drupal\Core\Theme\Registry;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests Stable's template overrides.
*
* @group Theme
*/
class StableTemplateOverrideTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['system', 'user'];
/**
* An array of template names to skip, without the extension.
*
* @var string[]
*/
protected $templatesToSkip = [
'views-form-views-form',
];
/**
* The theme handler.
*
* @var \Drupal\Core\Extension\ThemeHandlerInterface
*/
protected $themeHandler;
/**
* A list of all core modules.
*
* @var string[]
*/
protected $allModules;
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
$this->themeHandler = $this->container->get('theme_handler');
$this->container->get('theme_installer')->install(['stable']);
$this->installSchema('system', 'router');
$this->installAllModules();
}
/**
* Installs all core modules.
*/
protected function installAllModules() {
// Needed for system_rebuild_module_data().
include_once $this->root . '/core/modules/system/system.module';
// Enable all core modules.
$all_modules = system_rebuild_module_data();
$all_modules = array_filter($all_modules, function ($module) {
// Filter contrib, hidden, already enabled modules and modules in the
// Testing package.
if ($module->origin !== 'core' || !empty($module->info['hidden']) || $module->status == TRUE || $module->info['package'] == 'Testing') {
return FALSE;
}
return TRUE;
});
$this->allModules = array_keys($all_modules);
sort($this->allModules);
$module_installer = $this->container->get('module_installer');
$module_installer->install($this->allModules);
$this->installConfig(['system', 'user']);
}
/**
* Ensures that Stable overrides all relevant core templates.
*/
public function testStableTemplateOverrides() {
$registry = new Registry(\Drupal::root(), \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $this->themeHandler, \Drupal::service('theme.initialization'), 'stable');
$registry->setThemeManager(\Drupal::theme());
$registry_full = $registry->get();
foreach ($registry_full as $hook => $info) {
if (isset($info['template'])) {
// Allow skipping templates.
if (in_array($info['template'], $this->templatesToSkip)) {
continue;
}
$this->assertEquals('core/themes/stable', $info['theme path'], $info['template'] . '.html.twig overridden in Stable.');
}
}
}
}

View file

@ -0,0 +1,50 @@
<?php
/**
* @file
* Contains \Drupal\KernelTests\RequestProcessing\RedirectOnExceptionTest.
*/
namespace Drupal\KernelTests\RequestProcessing;
use Drupal\KernelTests\KernelTestBase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* Tests redirects on exception pages.
*
* @group request_processing
*/
class RedirectOnExceptionTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['system', 'test_page_test'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installSchema('system', ['router', 'url_alias']);
\Drupal::service('router.builder')->rebuild();
}
public function testRedirectOn404() {
\Drupal::configFactory()->getEditable('system.site')
->set('page.404', '/test-http-response-exception/' . Response::HTTP_PERMANENTLY_REDIRECT)
->save();
/** @var \Symfony\Component\HttpKernel\HttpKernelInterface $http_kernel */
$http_kernel = \Drupal::service('http_kernel');
// Foo doesn't exist, so this triggers the 404 page.
$request = Request::create('/foo');
$response = $http_kernel->handle($request);
$this->assertEquals(Response::HTTP_PERMANENTLY_REDIRECT, $response->getStatusCode());
}
}