diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index ac4afa5..bfc9384 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -17,6 +17,7 @@ use Drupal\Core\Config\NullStorage; use Drupal\Core\Database\Database; use Drupal\Core\DependencyInjection\ContainerBuilder; +use Drupal\Core\DependencyInjection\ServiceModifierInterface; use Drupal\Core\DependencyInjection\ServiceProviderInterface; use Drupal\Core\DependencyInjection\YamlFileLoader; use Drupal\Core\Extension\ExtensionDiscovery; @@ -574,7 +575,7 @@ public function discoverServiceProviders() { // Add site-specific service providers. if (!empty($GLOBALS['conf']['container_service_providers'])) { foreach ($GLOBALS['conf']['container_service_providers'] as $class) { - if (is_object($class) || class_exists($class)) { + if ((is_object($class) && ($class instanceof ServiceProviderInterface || $class instanceof ServiceModifierInterface)) || class_exists($class)) { $this->serviceProviderClasses['site'][] = $class; } } diff --git a/core/tests/Drupal/KernelTests/KernelTestBaseTest.php b/core/tests/Drupal/KernelTests/KernelTestBaseTest.php index b525a79..ae0da56 100644 --- a/core/tests/Drupal/KernelTests/KernelTestBaseTest.php +++ b/core/tests/Drupal/KernelTests/KernelTestBaseTest.php @@ -63,7 +63,7 @@ public function testGetDatabaseConnectionInfoWithOutManualSetDbUrl() { * @covers ::getDatabaseConnectionInfo */ public function testGetDatabaseConnectionInfoWithManualSetDbUrl() { - putenv('PHPUNIT_DBURL=sqlite://localhost/:memory:'); + putenv('SIMPLETEST_DB=sqlite://localhost/:memory:'); $this->setUp(); $options = $this->container->get('database')->getConnectionOptions(); diff --git a/core/tests/Drupal/Tests/KernelTestBase.php b/core/tests/Drupal/Tests/KernelTestBase.php index f3a7daa..76b25bb 100644 --- a/core/tests/Drupal/Tests/KernelTestBase.php +++ b/core/tests/Drupal/Tests/KernelTestBase.php @@ -184,7 +184,11 @@ protected $root; /** - * The name of the session cookie. + * Set to TRUE to strict check all configuration saved. + * + * @see \Drupal\Core\Config\Testing\ConfigSchemaChecker + * + * @var bool */ protected $strictConfigSchema = TRUE; @@ -271,6 +275,15 @@ protected function bootEnvironment() { Database::addConnectionInfo('default', 'default', $this->getDatabaseConnectionInfo()['default']); } + /** + * Parses a database URL into a connection info array. + * + * @param string $db_url + * The database URL. + * + * @return array + * The database connection info. + */ protected function parseDbUrl($db_url) { $info = parse_url($db_url); if (!isset($info['scheme'], $info['host'], $info['path'])) { @@ -285,7 +298,7 @@ protected function parseDbUrl($db_url) { $info['path'] = substr($info['path'], 1); } if ($info['scheme'] === 'sqlite' && $info['path'][0] !== '/') { - $info['path'] = DRUPAL_ROOT . '/' . $info['path']; + $info['path'] = $this->root . '/' . $info['path']; } $db_info = [ 'driver' => $info['scheme'], @@ -309,16 +322,16 @@ protected function parseDbUrl($db_url) { private function bootKernel() { $this->setSetting('container_yamls', []); // Allow for test-specific overrides. - $settings_services_file = DRUPAL_ROOT . '/sites/default' . '/testing.services.yml'; + $settings_services_file = $this->root . '/sites/default' . '/testing.services.yml'; if (file_exists($settings_services_file)) { // Copy the testing-specific service overrides in place. - $testing_services_file = DRUPAL_ROOT . '/' . $this->siteDirectory . '/services.yml'; + $testing_services_file = $this->root . '/' . $this->siteDirectory . '/services.yml'; copy($settings_services_file, $testing_services_file); $this->settingsSet('container_yamls', [$testing_services_file]); } // Allow for global test environment overrides. - if (file_exists($test_env = DRUPAL_ROOT . '/sites/default/testing.services.yml')) { + if (file_exists($test_env = $this->root . '/sites/default/testing.services.yml')) { $GLOBALS['conf']['container_yamls']['testing'] = $test_env; } // Add this test class as a service provider. @@ -777,7 +790,7 @@ protected function installEntitySchema($entity_type_id) { protected function enableModules(array $modules) { $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); if ($trace[1]['function'] === 'setUp') { - $this->triggerDeprecated('KernelTestBase::enableModules() should not be called from setUp(). Use the $modules property instead.'); + trigger_error('KernelTestBase::enableModules() should not be called from setUp(). Use the $modules property instead.', E_DEPRECATED); } unset($trace); @@ -899,7 +912,7 @@ protected function setSetting($name, $value) { * @see \Drupal\Tests\KernelTestBase::setSetting() */ protected function settingsSet($name, $value) { - $this->triggerDeprecated(sprintf("KernelTestBase::%s() is deprecated. Use setSetting() instead.", __FUNCTION__)); + trigger_error(sprintf("KernelTestBase::%s() is deprecated. Use setSetting() instead.", __FUNCTION__), E_DEPRECATED); $this->setSetting($name, $value); } @@ -1106,7 +1119,7 @@ public function __get($name) { } if ($name === 'configDirectories') { - $this->triggerDeprecated(sprintf("KernelTestBase::\$%s no longer exists. Use config_get_config_directory() directly instead.", $name)); + trigger_error(sprintf("KernelTestBase::\$%s no longer exists. Use config_get_config_directory() directly instead.", $name), E_DEPRECATED); return array( CONFIG_ACTIVE_DIRECTORY => config_get_config_directory(CONFIG_ACTIVE_DIRECTORY), CONFIG_STAGING_DIRECTORY => config_get_config_directory(CONFIG_STAGING_DIRECTORY), @@ -1153,28 +1166,4 @@ public function __set($name, $value) { $this->__get($name); } - /** - * Triggers a test framework feature deprecation warning. - * - * Does not halt test execution. - * - * @param string $message - * The plain-text message to output (on CLI). - */ - private function triggerDeprecated($message) { - // PHPUnit_Util_DeprecatedFeature no longer exists and is replaced by simply - // triggering E_USER_DEPRECATED errors in upcoming PHPUnit versions. - // @todo Remove this entire method after upgrading. - if (class_exists('PHPUnit_Util_DeprecatedFeature')) { - $message = get_class($this) . '::' . $this->getName() . "\n" . $message; - $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); - $this->getTestResultObject()->addDeprecatedFeature( - new \PHPUnit_Util_DeprecatedFeature($message, $trace[1]) - ); - } - else { - trigger_error($message, E_USER_DEPRECATED); - } - } - } diff --git a/core/tests/Drupal/Tests/LogException.php b/core/tests/Drupal/Tests/LogException.php deleted file mode 100644 index f84139a..0000000 --- a/core/tests/Drupal/Tests/LogException.php +++ /dev/null @@ -1,49 +0,0 @@ -severity = $severity; - } - - /** - * {@inheritdoc} - */ - public function toString() { - $names = ['EMERGENCY', 'ALERT', 'CRITICAL', 'ERROR', 'WARNING', 'NOTICE', 'INFO', 'DEBUG']; - if (isset($names[$this->severity])) { - $name = 'WATCHDOG_' . $names[$this->severity]; - } - else { - $name = 'UNKNOWN'; - } - return $name . ': ' . $this->getMessage(); - } - -} diff --git a/core/tests/Drupal/Tests/VfsStreamWrapperWrapper.php b/core/tests/Drupal/Tests/VfsStreamWrapperWrapper.php deleted file mode 100644 index cf0dda8..0000000 --- a/core/tests/Drupal/Tests/VfsStreamWrapperWrapper.php +++ /dev/null @@ -1,151 +0,0 @@ -streamWrapper = new VfsStreamWrapper; - } - - public function dir_closedir() { - return $this->streamWrapper->dir_closedir(); - } - - public function dir_opendir($path, $options) { - return $this->streamWrapper->dir_opendir($path, $options); - } - - public function dir_readdir() { - return $this->streamWrapper->dir_readdir(); - } - - public function dir_rewinddir() { - return $this->streamWrapper->dir_rewinddir(); - } - - public function mkdir($path, $mode, $options) { - return $this->streamWrapper->mkdir($path, $mode, $options); - } - - public function rename($path_from, $path_to) { - return $this->streamWrapper->rename($path_from, $path_to); - } - - public function rmdir($path, $options) { - return $this->streamWrapper->rmdir($path, $options); - } - - public function stream_cast($cast_as) { - return $this->streamWrapper->stream_cast($cast_as); - } - - public function stream_close() { - $this->streamWrapper->stream_close(); - } - - public function stream_eof() { - return $this->streamWrapper->stream_eof(); - } - - public function stream_flush() { - return $this->streamWrapper->stream_flush(); - } - - public function stream_lock($operation) { - return $this->streamWrapper->stream_lock($operation); - } - - public function stream_metadata($path, $option, $value) { - return $this->streamWrapper->stream_metadata($path, $option, $value); - } - - public function stream_open($path, $mode, $options, &$opened_path) { - return $this->streamWrapper->stream_open($path, $mode, $options, $opened_path); - } - - public function stream_read($count) { - return $this->streamWrapper->stream_read($count); - } - - public function stream_seek($offset, $whence = SEEK_SET) { - return $this->streamWrapper->stream_seek($offset, $whence = SEEK_SET); - } - - public function stream_set_option($option, $arg1, $arg2) { - return $this->streamWrapper->stream_set_option($option, $arg1, $arg2); - } - - public function stream_stat() { - return $this->streamWrapper->stream_stat(); - } - - public function stream_tell() { - return $this->streamWrapper->stream_tell(); - } - - public function stream_truncate($new_size) { - return $this->streamWrapper->stream_truncate($new_size); - } - - public function stream_write($data) { - return $this->streamWrapper->stream_write($data); - } - - public function unlink($path) { - return $this->streamWrapper->unlink($path); - } - - public function url_stat($path, $flags) { - return $this->streamWrapper->url_stat($path, $flags); - } - - public static function getType() { - return StreamWrapperInterface::ALL; - } - - public function getName() { - return 'vfs'; - } - - public function getDescription() { - return 'virtual file system.'; - } - - public function setUri($uri) { - $this->uri = $uri; - } - - public function getUri() { - return $this->uri; - } - - public function getExternalUrl() { - return NULL; - } - - public function realpath() { - return NULL; - } - - public function dirname($uri = NULL) { - $list = explode('/', $uri); - array_pop($list); - return implode('/', $list); - } - - public function getDirectoryPath() { - return 'root'; - } - -}