diff --git a/core/modules/system/tests/src/Kernel/File/FileTestBase.php b/core/modules/system/tests/src/Kernel/File/FileTestBase.php index dccbef2..b6939ac 100644 --- a/core/modules/system/tests/src/Kernel/File/FileTestBase.php +++ b/core/modules/system/tests/src/Kernel/File/FileTestBase.php @@ -7,7 +7,7 @@ namespace Drupal\Tests\system\Kernel\File; -use Drupal\Core\StreamWrapper\StreamWrapperInterface; +use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\KernelTests\KernelTestBase; /** @@ -37,17 +37,46 @@ */ protected $classname; + /** + * {@inheritdoc} + */ protected function setUp() { parent::setUp(); - $this->installConfig(array('system')); - $this->container->get('stream_wrapper_manager')->registerWrapper('private', 'Drupal\Core\StreamWrapper\PrivateStream', StreamWrapperInterface::NORMAL); + + \Drupal::configFactory()->getEditable('system.file')->set('default_scheme', 'public')->save(); + } + + /** + * {@inheritdoc} + */ + public function register(ContainerBuilder $container) { + parent::register($container); + + $container->register('stream_wrapper.private', 'Drupal\Core\StreamWrapper\PrivateStream') + ->addTag('stream_wrapper', ['scheme' => 'private']); if (isset($this->scheme)) { - $this->container->get('stream_wrapper_manager')->registerWrapper($this->scheme, $this->classname, StreamWrapperInterface::NORMAL); + $container->register('stream_wrapper.' . $this->scheme, $this->classname) + ->addTag('stream_wrapper', ['scheme' => $this->scheme]); } } /** + * {@inheritdoc} + */ + protected function setUpFilesystem() { + $public_file_directory = $this->siteDirectory . '/files'; + + require_once 'core/includes/file.inc'; + + mkdir($this->siteDirectory, 0775); + mkdir($this->siteDirectory . '/files', 0775); + mkdir($this->siteDirectory . '/files/config/' . CONFIG_SYNC_DIRECTORY, 0775, TRUE); + + $this->setSetting('file_public_path', $public_file_directory); + } + + /** * Helper function to test the permissions of a file. * * @param $filepath diff --git a/core/modules/system/tests/src/Kernel/KeyValueStore/DatabaseStorageExpirableTest.php b/core/modules/system/tests/src/Kernel/KeyValueStore/DatabaseStorageExpirableTest.php index 4aa2463..3ef0711 100644 --- a/core/modules/system/tests/src/Kernel/KeyValueStore/DatabaseStorageExpirableTest.php +++ b/core/modules/system/tests/src/Kernel/KeyValueStore/DatabaseStorageExpirableTest.php @@ -34,8 +34,8 @@ protected function setUp() { /** * {@inheritdoc} */ - public function containerBuild(ContainerBuilder $container) { - parent::containerBuild($container); + public function register(ContainerBuilder $container) { + parent::register($container); $parameter[KeyValueFactory::DEFAULT_SETTING] = 'keyvalue.expirable.database'; $container->setParameter('factory.keyvalue.expirable', $parameter); diff --git a/core/modules/system/tests/src/Kernel/Routing/RouteProviderTest.php b/core/modules/system/tests/src/Kernel/Routing/RouteProviderTest.php index 151946a..409ef24 100644 --- a/core/modules/system/tests/src/Kernel/Routing/RouteProviderTest.php +++ b/core/modules/system/tests/src/Kernel/Routing/RouteProviderTest.php @@ -92,7 +92,7 @@ protected function setUp() { * {@inheritdoc} */ public function register(ContainerBuilder $container) { - parent::register($container); // TODO: Change the autogenerated stub + parent::register($container); // Readd the incoming path alias for these tests. if ($container->hasDefinition('path_processor_alias')) { @@ -185,8 +185,7 @@ function testOutlinePathMatch() { // All of the matching paths have the correct pattern. foreach ($routes as $route) { - $this->assertEqual($route->compile() - ->getPatternOutline(), '/path/%/one', 'Found path has correct pattern'); + $this->assertEqual($route->compile()->getPatternOutline(), '/path/%/one', 'Found path has correct pattern'); } $this->assertEqual(count($routes), 2, 'The correct number of routes was found.'); @@ -215,8 +214,7 @@ function testOutlinePathMatchTrailingSlash() { // All of the matching paths have the correct pattern. foreach ($routes as $route) { - $this->assertEqual($route->compile() - ->getPatternOutline(), '/path/%/one', 'Found path has correct pattern'); + $this->assertEqual($route->compile()->getPatternOutline(), '/path/%/one', 'Found path has correct pattern'); } $this->assertEqual(count($routes), 2, 'The correct number of routes was found.'); @@ -251,13 +249,13 @@ function testOutlinePathMatchDefaults() { // All of the matching paths have the correct pattern. foreach ($routes as $route) { - $this->assertEqual($route->compile() - ->getPatternOutline(), '/some/path', 'Found path has correct pattern'); + $this->assertEqual($route->compile()->getPatternOutline(), '/some/path', 'Found path has correct pattern'); } $this->assertEqual(count($routes), 1, 'The correct number of routes was found.'); $this->assertNotNull($routes->get('poink'), 'The first matching route was found.'); - } catch (ResourceNotFoundException $e) { + } + catch (ResourceNotFoundException $e) { $this->fail('No matching route found with default argument value.'); } } @@ -290,13 +288,13 @@ function testOutlinePathMatchDefaultsCollision() { // All of the matching paths have the correct pattern. foreach ($routes as $route) { - $this->assertEqual($route->compile() - ->getPatternOutline(), '/some/path', 'Found path has correct pattern'); + $this->assertEqual($route->compile()->getPatternOutline(), '/some/path', 'Found path has correct pattern'); } $this->assertEqual(count($routes), 1, 'The correct number of routes was found.'); $this->assertNotNull($routes->get('poink'), 'The first matching route was found.'); - } catch (ResourceNotFoundException $e) { + } + catch (ResourceNotFoundException $e) { $this->fail('No matching route found with default argument value.'); } } @@ -330,14 +328,12 @@ function testOutlinePathMatchDefaultsCollision2() { $routes_array = $routes->all(); $this->assertEqual(count($routes), 2, 'The correct number of routes was found.'); - $this->assertEqual(array( - 'narf', - 'poink' - ), array_keys($routes_array), 'Ensure the fitness was taken into account.'); + $this->assertEqual(array('narf', 'poink'), array_keys($routes_array), 'Ensure the fitness was taken into account.'); $this->assertNotNull($routes->get('narf'), 'The first matching route was found.'); $this->assertNotNull($routes->get('poink'), 'The second matching route was found.'); $this->assertNull($routes->get('eep'), 'Non-matching route was not found.'); - } catch (ResourceNotFoundException $e) { + } + catch (ResourceNotFoundException $e) { $this->fail('No matching route found with default argument value.'); } } @@ -371,14 +367,12 @@ function testOutlinePathMatchDefaultsCollision3() { $routes_array = $routes->all(); $this->assertEqual(count($routes), 2, 'The correct number of routes was found.'); - $this->assertEqual(array( - 'poink', - 'poink2' - ), array_keys($routes_array), 'Ensure the fitness and name were taken into account in the sort.'); + $this->assertEqual(array('poink', 'poink2'), array_keys($routes_array), 'Ensure the fitness and name were taken into account in the sort.'); $this->assertNotNull($routes->get('poink'), 'The first matching route was found.'); $this->assertNotNull($routes->get('poink2'), 'The second matching route was found.'); $this->assertNull($routes->get('eep'), 'Non-matching route was not found.'); - } catch (ResourceNotFoundException $e) { + } + catch (ResourceNotFoundException $e) { $this->fail('No matching route found with default argument value.'); } } @@ -408,12 +402,12 @@ public function testOutlinePathMatchZero() { // All of the matching paths have the correct pattern. foreach ($routes as $route) { - $this->assertEqual($route->compile() - ->getPatternOutline(), '/some/path/%', 'Found path has correct pattern'); + $this->assertEqual($route->compile()->getPatternOutline(), '/some/path/%', 'Found path has correct pattern'); } $this->assertEqual(count($routes), 1, 'The correct number of routes was found.'); - } catch (ResourceNotFoundException $e) { + } + catch (ResourceNotFoundException $e) { $this->fail('No matchout route found with 0 as argument value'); } } @@ -528,16 +522,13 @@ public function testRouteByName() { $exception_thrown = FALSE; try { $provider->getRouteByName('invalid_name'); - } catch (RouteNotFoundException $e) { + } + catch (RouteNotFoundException $e) { $exception_thrown = TRUE; } $this->assertTrue($exception_thrown, 'Random route was not found.'); - $routes = $provider->getRoutesByNames(array( - 'route_c', - 'route_d', - $this->randomMachineName() - )); + $routes = $provider->getRoutesByNames(array('route_c', 'route_d', $this->randomMachineName())); $this->assertEqual(count($routes), 2, 'Only two valid routes found.'); $this->assertEqual($routes['route_c']->getPath(), '/path/two'); $this->assertEqual($routes['route_d']->getPath(), '/path/three'); diff --git a/core/tests/Drupal/KernelTests/Core/KeyValueStore/MemoryStorageTest.php b/core/tests/Drupal/KernelTests/Core/KeyValueStore/MemoryStorageTest.php index 94ee630..8d10b69 100644 --- a/core/tests/Drupal/KernelTests/Core/KeyValueStore/MemoryStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/KeyValueStore/MemoryStorageTest.php @@ -9,7 +9,6 @@ use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\KeyValueStore\KeyValueFactory; -use Drupal\KernelTests\Core\KeyValueStore\StorageTestBase; /** * Tests the key-value memory storage. diff --git a/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/AnnotatedClassDiscoveryTest.php b/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/AnnotatedClassDiscoveryTest.php index 58c095e..75d3535 100644 --- a/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/AnnotatedClassDiscoveryTest.php +++ b/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/AnnotatedClassDiscoveryTest.php @@ -8,7 +8,6 @@ namespace Drupal\KernelTests\Core\Plugin\Discovery; use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery; -use Drupal\KernelTests\Core\Plugin\Discovery\DiscoveryTestBase; /** * Tests that plugins are correctly discovered using annotated classes. diff --git a/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/CustomAnnotationClassDiscoveryTest.php b/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/CustomAnnotationClassDiscoveryTest.php index 2ebe95c..8ad913f 100644 --- a/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/CustomAnnotationClassDiscoveryTest.php +++ b/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/CustomAnnotationClassDiscoveryTest.php @@ -8,7 +8,6 @@ namespace Drupal\KernelTests\Core\Plugin\Discovery; use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery; -use Drupal\KernelTests\Core\Plugin\Discovery\DiscoveryTestBase; /** * Tests that a custom annotation class is used. diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php index 9587ed2..343a652 100644 --- a/core/tests/Drupal/KernelTests/KernelTestBase.php +++ b/core/tests/Drupal/KernelTests/KernelTestBase.php @@ -266,18 +266,6 @@ protected function bootEnvironment() { $this->databasePrefix = 'simpletest' . $suffix; } while (is_dir($this->root . '/' . $this->siteDirectory)); - $this->vfsRoot = vfsStream::setup('root', NULL, array( - 'sites' => array( - 'simpletest' => array( - $suffix => array(), - ), - ), - )); - $this->siteDirectory = vfsStream::url('root/sites/simpletest/' . $suffix); - - mkdir($this->siteDirectory . '/files', 0775); - mkdir($this->siteDirectory . '/files/config/' . CONFIG_SYNC_DIRECTORY, 0775, TRUE); - // Ensure that all code that relies on drupal_valid_test_ua() can still be // safely executed. This primarily affects the (test) site directory // resolution (used by e.g. LocalStream and PhpStorage). @@ -304,6 +292,24 @@ protected function bootEnvironment() { } /** + * Sets up the filesystem, so things like the file directory. + */ + protected function setUpFilesystem() { + $suffix = str_replace('simpletest', '', $this->databasePrefix); + $this->vfsRoot = vfsStream::setup('root', NULL, array( + 'sites' => array( + 'simpletest' => array( + $suffix => array(), + ), + ), + )); + $this->siteDirectory = vfsStream::url('root/sites/simpletest/' . $suffix); + + mkdir($this->siteDirectory . '/files', 0775); + mkdir($this->siteDirectory . '/files/config/' . CONFIG_SYNC_DIRECTORY, 0775, TRUE); + } + + /** * @return string */ public function getDatabasePrefix() { @@ -405,6 +411,8 @@ private function bootKernel() { // While this should be enforced via settings.php prior to installation, // some tests expect to be able to test mail system implementations. $GLOBALS['config']['system.mail']['interface']['default'] = 'test_mail_collector'; + + $this->setUpFilesystem(); } /**