Update to Drupal 8.0.2. For more information, see https://www.drupal.org/drupal-8.0.2-release-notes
This commit is contained in:
parent
1a0e9d9fac
commit
a6b049dd05
538 changed files with 5247 additions and 1594 deletions
|
@ -41,11 +41,6 @@ use Symfony\Component\HttpFoundation\Request;
|
|||
* Drupal\Tests\yourmodule\Functional namespace and live in the
|
||||
* modules/yourmodule/Tests/Functional directory.
|
||||
*
|
||||
* All BrowserTestBase tests must have two annotations to ensure process
|
||||
* isolation:
|
||||
* - @runTestsInSeparateProcesses
|
||||
* - @preserveGlobalState disabled
|
||||
*
|
||||
* @ingroup testing
|
||||
*
|
||||
* @see \Drupal\simpletest\WebTestBase
|
||||
|
@ -216,6 +211,19 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
|
|||
*/
|
||||
protected $mink;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Browser tests are run in separate processes to prevent collisions between
|
||||
* code that may be loaded by tests.
|
||||
*/
|
||||
protected $runTestInSeparateProcess = TRUE;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $preserveGlobalState = FALSE;
|
||||
|
||||
/**
|
||||
* Initializes Mink sessions.
|
||||
*/
|
||||
|
@ -291,7 +299,7 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
|
|||
// coverage against.
|
||||
$base_url = getenv('SIMPLETEST_BASE_URL');
|
||||
if (!$base_url) {
|
||||
$this->markTestSkipped(
|
||||
throw new \Exception(
|
||||
'You must provide a SIMPLETEST_BASE_URL environment variable to run some PHPUnit based functional tests.'
|
||||
);
|
||||
}
|
||||
|
@ -800,24 +808,6 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
|
|||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override to use Mink exceptions.
|
||||
*
|
||||
* @return mixed
|
||||
* Either a test result or NULL.
|
||||
*
|
||||
* @throws \PHPUnit_Framework_AssertionFailedError
|
||||
* When exception was thrown inside the test.
|
||||
*/
|
||||
protected function runTest() {
|
||||
try {
|
||||
return parent::runTest();
|
||||
}
|
||||
catch (Exception $e) {
|
||||
throw new \PHPUnit_Framework_AssertionFailedError($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs Drupal into the Simpletest site.
|
||||
*/
|
||||
|
@ -1338,4 +1328,22 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
|
|||
return $logged_in;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevents serializing any properties.
|
||||
*
|
||||
* Browser tests are run in a separate process. To do this PHPUnit creates a
|
||||
* script to run the test. If it fails, the test result object will contain a
|
||||
* stack trace which includes the test object. It will attempt to serialize
|
||||
* it. Returning an empty array prevents it from serializing anything it
|
||||
* should not.
|
||||
*
|
||||
* @return array
|
||||
* An empty array.
|
||||
*
|
||||
* @see vendor/phpunit/phpunit/src/Util/PHP/Template/TestCaseMethod.tpl.dist
|
||||
*/
|
||||
public function __sleep() {
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -485,6 +485,12 @@ EOD;
|
|||
/**
|
||||
* Enables modules for this test.
|
||||
*
|
||||
* To install test modules outside of the testing environment, add
|
||||
* @code
|
||||
* $settings['extension_discovery_scan_tests'] = TRUE;
|
||||
* @encode
|
||||
* to your settings.php.
|
||||
*
|
||||
* @param array $modules
|
||||
* A list of modules to enable. Dependencies are not resolved; i.e.,
|
||||
* multiple modules have to be specified with dependent modules first.
|
||||
|
@ -518,7 +524,8 @@ EOD;
|
|||
$module_filenames = $module_handler->getModuleList();
|
||||
$this->kernel->updateModules($module_filenames, $module_filenames);
|
||||
|
||||
// Ensure isLoaded() is TRUE in order to make _theme() work.
|
||||
// Ensure isLoaded() is TRUE in order to make
|
||||
// \Drupal\Core\Theme\ThemeManagerInterface::render() work.
|
||||
// Note that the kernel has rebuilt the container; this $module_handler is
|
||||
// no longer the $module_handler instance from above.
|
||||
$this->container->get('module_handler')->reload();
|
||||
|
@ -551,7 +558,8 @@ EOD;
|
|||
// Update the kernel to remove their services.
|
||||
$this->kernel->updateModules($module_filenames, $module_filenames);
|
||||
|
||||
// Ensure isLoaded() is TRUE in order to make _theme() work.
|
||||
// Ensure isLoaded() is TRUE in order to make
|
||||
// \Drupal\Core\Theme\ThemeManagerInterface::render() work.
|
||||
// Note that the kernel has rebuilt the container; this $module_handler is
|
||||
// no longer the $module_handler instance from above.
|
||||
$module_handler = $this->container->get('module_handler');
|
||||
|
|
114
core/modules/simpletest/src/RouteProvider.php
Normal file
114
core/modules/simpletest/src/RouteProvider.php
Normal file
|
@ -0,0 +1,114 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\ProxyClass\Routing\RouteProvider.
|
||||
*/
|
||||
|
||||
namespace Drupal\simpletest;
|
||||
|
||||
use Drupal\Core\Routing\PreloadableRouteProviderInterface;
|
||||
use Symfony\Cmf\Component\Routing\PagedRouteProviderInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Rebuilds the router when the provider is instantiated.
|
||||
*/
|
||||
class RouteProvider implements PreloadableRouteProviderInterface, PagedRouteProviderInterface {
|
||||
|
||||
use \Drupal\Core\DependencyInjection\DependencySerializationTrait;
|
||||
|
||||
/**
|
||||
* Loads the real route provider from the container and rebuilds the router.
|
||||
*
|
||||
* @return \Drupal\Core\Routing\PreloadableRouteProviderInterface|\Symfony\Cmf\Component\Routing\PagedRouteProviderInterface|\Symfony\Component\EventDispatcher\EventSubscriberInterface
|
||||
* The route provider.
|
||||
*/
|
||||
protected function lazyLoadItself() {
|
||||
if (!isset($this->service)) {
|
||||
$container = \Drupal::getContainer();
|
||||
$this->service = $container->get('simpletest.router.route_provider');
|
||||
$container->get('router.builder')->rebuild();
|
||||
}
|
||||
|
||||
return $this->service;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRouteCollectionForRequest(Request $request) {
|
||||
return $this->lazyLoadItself()->getRouteCollectionForRequest($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRouteByName($name) {
|
||||
return $this->lazyLoadItself()->getRouteByName($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function preLoadRoutes($names){
|
||||
return $this->lazyLoadItself()->preLoadRoutes($names);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRoutesByNames($names) {
|
||||
return $this->lazyLoadItself()->getRoutesByNames($names);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCandidateOutlines(array $parts) {
|
||||
return $this->lazyLoadItself()->getCandidateOutlines($parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRoutesByPattern($pattern) {
|
||||
return $this->lazyLoadItself()->getRoutesByPattern($pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function routeProviderRouteCompare(array $a, array $b) {
|
||||
return $this->lazyLoadItself()->routeProviderRouteCompare($a, $b);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAllRoutes() {
|
||||
return $this->lazyLoadItself()->getAllRoutes();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function reset() {
|
||||
return $this->lazyLoadItself()->reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRoutesPaged($offset, $length = NULL) {
|
||||
return $this->lazyLoadItself()->getRoutesPaged($offset, $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRoutesCount() {
|
||||
return $this->lazyLoadItself()->getRoutesCount();
|
||||
}
|
||||
|
||||
}
|
|
@ -96,7 +96,7 @@ abstract class TestBase {
|
|||
/**
|
||||
* Incrementing identifier for verbose output filenames.
|
||||
*
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
protected $verboseId = 0;
|
||||
|
||||
|
|
|
@ -8,9 +8,11 @@
|
|||
namespace Drupal\simpletest;
|
||||
|
||||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
use Drupal\Core\DependencyInjection\ServiceModifierInterface;
|
||||
use Drupal\Core\DependencyInjection\ServiceProviderInterface;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
|
||||
class TestServiceProvider implements ServiceProviderInterface {
|
||||
class TestServiceProvider implements ServiceProviderInterface, ServiceModifierInterface {
|
||||
|
||||
/**
|
||||
* @var \Drupal\simpletest\TestBase;
|
||||
|
@ -25,4 +27,21 @@ class TestServiceProvider implements ServiceProviderInterface {
|
|||
static::$currentTest->containerBuild($container);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function alter(ContainerBuilder $container) {
|
||||
if (static::$currentTest instanceof KernelTestBase) {
|
||||
// While $container->get() does a recursive resolve, getDefinition() does
|
||||
// not, so do it ourselves.
|
||||
foreach (['router.route_provider' => 'RouteProvider'] as $original_id => $class) {
|
||||
for ($id = $original_id; $container->hasAlias($id); $id = (string) $container->getAlias($id));
|
||||
$definition = $container->getDefinition($id);
|
||||
$definition->clearTag('needs_destruction');
|
||||
$container->setDefinition("simpletest.$original_id", $definition);
|
||||
$container->setDefinition($id, new Definition('Drupal\simpletest\\' . $class));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -290,7 +290,7 @@ EOS;
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests that _theme() works right after loading a module.
|
||||
* Tests that ThemeManager works right after loading a module.
|
||||
*/
|
||||
function testEnableModulesTheme() {
|
||||
/** @var \Drupal\Core\Render\RendererInterface $renderer */
|
||||
|
@ -301,7 +301,8 @@ EOS;
|
|||
'#attributes' => array(),
|
||||
);
|
||||
$this->enableModules(array('system'));
|
||||
// _theme() throws an exception if modules are not loaded yet.
|
||||
// \Drupal\Core\Theme\ThemeManager::render() throws an exception if modules
|
||||
// are not loaded yet.
|
||||
$this->assertTrue($renderer->renderRoot($element));
|
||||
|
||||
$element = $original_element;
|
||||
|
|
|
@ -24,7 +24,7 @@ class SimpleTestBrowserTest extends WebTestBase {
|
|||
*/
|
||||
public static $modules = array('simpletest', 'test_page_test');
|
||||
|
||||
public function setUp() {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
// Create and log in an admin user.
|
||||
$this->drupalLogin($this->drupalCreateUser(array('administer unit tests')));
|
||||
|
|
|
@ -92,7 +92,7 @@ trait UserCreationTrait {
|
|||
* (optional) The role ID (machine name). Defaults to a random name.
|
||||
* @param string $name
|
||||
* (optional) The label for the role. Defaults to a random string.
|
||||
* @param integer $weight
|
||||
* @param int $weight
|
||||
* (optional) The weight for the role. Defaults NULL so that entity_create()
|
||||
* sets the weight to maximum + 1.
|
||||
*
|
||||
|
@ -119,7 +119,7 @@ trait UserCreationTrait {
|
|||
* (optional) The role ID (machine name). Defaults to a random name.
|
||||
* @param string $name
|
||||
* (optional) The label for the role. Defaults to a random string.
|
||||
* @param integer $weight
|
||||
* @param int $weight
|
||||
* (optional) The weight for the role. Defaults NULL so that entity_create()
|
||||
* sets the weight to maximum + 1.
|
||||
*
|
||||
|
|
|
@ -1010,6 +1010,12 @@ abstract class WebTestBase extends TestBase {
|
|||
/**
|
||||
* Install modules defined by `static::$modules`.
|
||||
*
|
||||
* To install test modules outside of the testing environment, add
|
||||
* @code
|
||||
* $settings['extension_discovery_scan_tests'] = TRUE;
|
||||
* @encode
|
||||
* to your settings.php.
|
||||
*
|
||||
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
|
||||
* The container.
|
||||
*/
|
||||
|
|
|
@ -17,6 +17,7 @@ class SimpletestPhpunitRunCommandTestWillDie extends UnitTestCase {
|
|||
if (getenv('SimpletestPhpunitRunCommandTestWillDie') === 'fail') {
|
||||
exit(2);
|
||||
}
|
||||
$this->assertTrue(TRUE, 'Assertion to ensure test pass');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,9 +13,6 @@ use Drupal\simpletest\BrowserTestBase;
|
|||
* Tests BrowserTestBase functionality.
|
||||
*
|
||||
* @group simpletest
|
||||
*
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
class BrowserTestBaseTest extends BrowserTestBase {
|
||||
|
||||
|
|
Reference in a new issue