当前位置: 首页>>代码示例>>PHP>>正文


PHP Drupal::unsetContainer方法代码示例

本文整理汇总了PHP中Drupal::unsetContainer方法的典型用法代码示例。如果您正苦于以下问题:PHP Drupal::unsetContainer方法的具体用法?PHP Drupal::unsetContainer怎么用?PHP Drupal::unsetContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal的用法示例。


在下文中一共展示了Drupal::unsetContainer方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     \Drupal::unsetContainer();
     parent::setUp();
     $this->installSchema('system', ['router', 'url_alias']);
     \Drupal::service('router.builder')->rebuild();
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:10,代码来源:ContentNegotiationRoutingTest.php

示例2: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Ensure that an instantiated container in the global state of \Drupal from
     // a previous test does not leak into this test.
     \Drupal::unsetContainer();
     $this->root = dirname(dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__))));
 }
开发者ID:brstde,项目名称:gap1,代码行数:11,代码来源:UnitTestCase.php

示例3: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Store the previous container.
     $this->previousContainer = $this->container;
     $this->container = NULL;
     \Drupal::unsetContainer();
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:11,代码来源:GetFilenameUnitTest.php

示例4: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Ensure that an instantiated container in the global state of \Drupal from
     // a previous test does not leak into this test.
     \Drupal::unsetContainer();
     // Ensure that the NullFileCache implementation is used for the FileCache as
     // unit tests should not be relying on caches implicitly.
     FileCacheFactory::setConfiguration(['default' => ['class' => '\\Drupal\\Component\\FileCache\\NullFileCache']]);
     $this->root = dirname(dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__))));
 }
开发者ID:alexburrows,项目名称:cream-2.x,代码行数:14,代码来源:UnitTestCase.php

示例5: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Ensure that an instantiated container in the global state of \Drupal from
     // a previous test does not leak into this test.
     \Drupal::unsetContainer();
     // Ensure that the NullFileCache implementation is used for the FileCache as
     // unit tests should not be relying on caches implicitly.
     FileCacheFactory::setConfiguration([FileCacheFactory::DISABLE_CACHE => TRUE]);
     // Ensure that FileCacheFactory has a prefix.
     FileCacheFactory::setPrefix('prefix');
     $this->root = dirname(dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__))));
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:16,代码来源:UnitTestCase.php

示例6: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Ensure that an instantiated container in the global state of \Drupal from
     // a previous test does not leak into this test.
     \Drupal::unsetContainer();
     // Ensure that the NullFileCache implementation is used for the FileCache as
     // unit tests should not be relying on caches implicitly.
     FileCacheFactory::setConfiguration(['default' => ['class' => '\\Drupal\\Component\\FileCache\\NullFileCache']]);
     $this->root = dirname(dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__))));
     // Reset the static list of SafeStrings to prevent bleeding between tests.
     $reflected_class = new \ReflectionClass('\\Drupal\\Component\\Utility\\SafeMarkup');
     $reflected_property = $reflected_class->getProperty('safeStrings');
     $reflected_property->setAccessible(true);
     $reflected_property->setValue([]);
 }
开发者ID:ravindrasingh22,项目名称:Drupal-8-rc,代码行数:19,代码来源:UnitTestCase.php

示例7: getDatabaseTypes

 /**
  * Returns all supported database driver installer objects.
  *
  * This wraps drupal_get_database_types() for use without a current container.
  *
  * @return \Drupal\Core\Database\Install\Tasks[]
  *   An array of available database driver installer objects.
  */
 protected function getDatabaseTypes()
 {
     \Drupal::setContainer($this->originalContainer);
     $database_types = drupal_get_database_types();
     \Drupal::unsetContainer();
     return $database_types;
 }
开发者ID:Wylbur,项目名称:gj,代码行数:15,代码来源:WebTestBase.php

示例8: tearDown

 /**
  * {@inheritdoc}
  */
 public function tearDown()
 {
     \Drupal::unsetContainer();
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:7,代码来源:PaymentTest.php

示例9: prepareEnvironment

 /**
  * Prepares the current environment for running the test.
  *
  * Also sets up new resources for the testing environment, such as the public
  * filesystem and configuration directories.
  *
  * This method is private as it must only be called once by
  * BrowserTestBase::setUp() (multiple invocations for the same test would have
  * unpredictable consequences) and it must not be callable or overridable by
  * test classes.
  */
 protected function prepareEnvironment()
 {
     // Bootstrap Drupal so we can use Drupal's built in functions.
     $this->classLoader = (require __DIR__ . '/../../../../autoload.php');
     $request = Request::createFromGlobals();
     $kernel = TestRunnerKernel::createFromRequest($request, $this->classLoader);
     // TestRunnerKernel expects the working directory to be DRUPAL_ROOT.
     chdir(DRUPAL_ROOT);
     $kernel->prepareLegacyRequest($request);
     $this->prepareDatabasePrefix();
     $this->originalSiteDirectory = $kernel->findSitePath($request);
     // Create test directory ahead of installation so fatal errors and debug
     // information can be logged during installation process.
     file_prepare_directory($this->siteDirectory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
     // Prepare filesystem directory paths.
     $this->publicFilesDirectory = $this->siteDirectory . '/files';
     $this->privateFilesDirectory = $this->siteDirectory . '/private';
     $this->tempFilesDirectory = $this->siteDirectory . '/temp';
     $this->translationFilesDirectory = $this->siteDirectory . '/translations';
     // Ensure the configImporter is refreshed for each test.
     $this->configImporter = NULL;
     // Unregister all custom stream wrappers of the parent site.
     $wrappers = \Drupal::service('stream_wrapper_manager')->getWrappers(StreamWrapperInterface::ALL);
     foreach ($wrappers as $scheme => $info) {
         stream_wrapper_unregister($scheme);
     }
     // Reset statics.
     drupal_static_reset();
     // Ensure there is no service container.
     $this->container = NULL;
     \Drupal::unsetContainer();
     // Unset globals.
     unset($GLOBALS['config_directories']);
     unset($GLOBALS['config']);
     unset($GLOBALS['conf']);
     // Log fatal errors.
     ini_set('log_errors', 1);
     ini_set('error_log', DRUPAL_ROOT . '/' . $this->siteDirectory . '/error.log');
     // Change the database prefix.
     $this->changeDatabasePrefix();
     // After preparing the environment and changing the database prefix, we are
     // in a valid test environment.
     drupal_valid_test_ua($this->databasePrefix);
     // Reset settings.
     new Settings(array('hash_salt' => $this->databasePrefix));
     drupal_set_time_limit($this->timeLimit);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:58,代码来源:BrowserTestBase.php

示例10: prepareEnvironment

 /**
  * Prepares the current environment for running the test.
  *
  * Backups various current environment variables and resets them, so they do
  * not interfere with the Drupal site installation in which tests are executed
  * and can be restored in TestBase::restoreEnvironment().
  *
  * Also sets up new resources for the testing environment, such as the public
  * filesystem and configuration directories.
  *
  * This method is private as it must only be called once by TestBase::run()
  * (multiple invocations for the same test would have unpredictable
  * consequences) and it must not be callable or overridable by test classes.
  *
  * @see TestBase::beforePrepareEnvironment()
  */
 private function prepareEnvironment()
 {
     $user = \Drupal::currentUser();
     // Allow (base) test classes to backup global state information.
     $this->beforePrepareEnvironment();
     // Create the database prefix for this test.
     $this->prepareDatabasePrefix();
     $language_interface = \Drupal::languageManager()->getCurrentLanguage();
     // When running the test runner within a test, back up the original database
     // prefix.
     if (DRUPAL_TEST_IN_CHILD_SITE) {
         $this->originalPrefix = drupal_valid_test_ua();
     }
     // Backup current in-memory configuration.
     $site_path = \Drupal::service('site.path');
     $this->originalSite = $site_path;
     $this->originalSettings = Settings::getAll();
     $this->originalConfig = $GLOBALS['config'];
     // @todo Remove all remnants of $GLOBALS['conf'].
     // @see https://www.drupal.org/node/2183323
     $this->originalConf = isset($GLOBALS['conf']) ? $GLOBALS['conf'] : NULL;
     // Backup statics and globals.
     $this->originalContainer = clone \Drupal::getContainer();
     $this->originalLanguage = $language_interface;
     $this->originalConfigDirectories = $GLOBALS['config_directories'];
     // Save further contextual information.
     // Use the original files directory to avoid nesting it within an existing
     // simpletest directory if a test is executed within a test.
     $this->originalFileDirectory = Settings::get('file_public_path', $site_path . '/files');
     $this->originalProfile = drupal_get_profile();
     $this->originalUser = isset($user) ? clone $user : NULL;
     // Prevent that session data is leaked into the UI test runner by closing
     // the session and then setting the session-name (i.e. the name of the
     // session cookie) to a random value. If a test starts a new session, then
     // it will be associated with a different session-name. After the test-run
     // it can be safely destroyed.
     // @see TestBase::restoreEnvironment()
     if (PHP_SAPI !== 'cli' && session_status() === PHP_SESSION_ACTIVE) {
         session_write_close();
     }
     $this->originalSessionName = session_name();
     session_name('SIMPLETEST' . Crypt::randomBytesBase64());
     // Save and clean the shutdown callbacks array because it is static cached
     // and will be changed by the test run. Otherwise it will contain callbacks
     // from both environments and the testing environment will try to call the
     // handlers defined by the original one.
     $callbacks =& drupal_register_shutdown_function();
     $this->originalShutdownCallbacks = $callbacks;
     $callbacks = array();
     // Create test directory ahead of installation so fatal errors and debug
     // information can be logged during installation process.
     file_prepare_directory($this->siteDirectory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
     // Prepare filesystem directory paths.
     $this->publicFilesDirectory = $this->siteDirectory . '/files';
     $this->privateFilesDirectory = $this->siteDirectory . '/private';
     $this->tempFilesDirectory = $this->siteDirectory . '/temp';
     $this->translationFilesDirectory = $this->siteDirectory . '/translations';
     $this->generatedTestFiles = FALSE;
     // Ensure the configImporter is refreshed for each test.
     $this->configImporter = NULL;
     // Unregister all custom stream wrappers of the parent site.
     // Availability of Drupal stream wrappers varies by test base class:
     // - KernelTestBase supports and maintains stream wrappers in a custom
     //   way.
     // - WebTestBase re-initializes Drupal stream wrappers after installation.
     // The original stream wrappers are restored after the test run.
     // @see TestBase::restoreEnvironment()
     $this->originalContainer->get('stream_wrapper_manager')->unregister();
     // Reset statics.
     drupal_static_reset();
     // Ensure there is no service container.
     $this->container = NULL;
     \Drupal::unsetContainer();
     // Unset globals.
     unset($GLOBALS['config_directories']);
     unset($GLOBALS['config']);
     unset($GLOBALS['conf']);
     // Log fatal errors.
     ini_set('log_errors', 1);
     ini_set('error_log', DRUPAL_ROOT . '/' . $this->siteDirectory . '/error.log');
     // Change the database prefix.
     $this->changeDatabasePrefix();
     // After preparing the environment and changing the database prefix, we are
     // in a valid test environment.
//.........这里部分代码省略.........
开发者ID:ravindrasingh22,项目名称:Drupal-8-rc,代码行数:101,代码来源:TestBase.php

示例11: tearDown

 /**
  * {@inheritdoc}
  */
 protected function tearDown()
 {
     // Destroy the testing kernel.
     if (isset($this->kernel)) {
         $this->kernel->shutdown();
     }
     // Remove all prefixed tables.
     $original_connection_info = Database::getConnectionInfo('simpletest_original_default');
     $original_prefix = $original_connection_info['default']['prefix']['default'];
     $test_connection_info = Database::getConnectionInfo('default');
     $test_prefix = $test_connection_info['default']['prefix']['default'];
     if ($original_prefix != $test_prefix) {
         $tables = Database::getConnection()->schema()->findTables('%');
         foreach ($tables as $table) {
             if (Database::getConnection()->schema()->dropTable($table)) {
                 unset($tables[$table]);
             }
         }
     }
     // Free up memory: Own properties.
     $this->classLoader = NULL;
     $this->vfsRoot = NULL;
     $this->configImporter = NULL;
     // Free up memory: Custom test class properties.
     // Note: Private properties cannot be cleaned up.
     $rc = new \ReflectionClass(__CLASS__);
     $blacklist = array();
     foreach ($rc->getProperties() as $property) {
         $blacklist[$property->name] = $property->getDeclaringClass()->name;
     }
     $rc = new \ReflectionClass($this);
     foreach ($rc->getProperties(\ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED) as $property) {
         if (!$property->isStatic() && !isset($blacklist[$property->name])) {
             $this->{$property->name} = NULL;
         }
     }
     // Clean FileCache cache.
     FileCache::reset();
     // Clean up statics, container, and settings.
     if (function_exists('drupal_static_reset')) {
         drupal_static_reset();
     }
     \Drupal::unsetContainer();
     $this->container = NULL;
     new Settings(array());
     parent::tearDown();
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:50,代码来源:KernelTestBase.php

示例12: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     \Drupal::unsetContainer();
     parent::setUp();
     \Drupal::service('router.builder')->rebuild();
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:9,代码来源:ContentNegotiationRoutingTest.php

示例13: prepareConfigDirectories

 /**
  * {@inheritdoc}
  */
 protected function prepareConfigDirectories()
 {
     \Drupal::setContainer($this->originalContainer);
     parent::prepareConfigDirectories();
     \Drupal::unsetContainer();
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:9,代码来源:DrupalKernelTest.php

示例14: tearDown

 /**
  * {@inheritdoc}
  */
 protected function tearDown()
 {
     // Destroy the testing kernel.
     if (isset($this->kernel)) {
         $this->kernel->shutdown();
     }
     // Free up memory: Own properties.
     $this->classLoader = NULL;
     $this->vfsRoot = NULL;
     $this->configImporter = NULL;
     // Free up memory: Custom test class properties.
     // Note: Private properties cannot be cleaned up.
     $rc = new \ReflectionClass(__CLASS__);
     $blacklist = array();
     foreach ($rc->getProperties() as $property) {
         $blacklist[$property->name] = $property->getDeclaringClass()->name;
     }
     $rc = new \ReflectionClass($this);
     foreach ($rc->getProperties(\ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED) as $property) {
         if (!$property->isStatic() && !isset($blacklist[$property->name])) {
             $this->{$property->name} = NULL;
         }
     }
     // Clean up statics, container, and settings.
     if (function_exists('drupal_static_reset')) {
         drupal_static_reset();
     }
     \Drupal::unsetContainer();
     $this->container = NULL;
     new Settings(array());
     // Destroy the database connection, which for example removes the memory
     // from sqlite in memory.
     foreach (Database::getAllConnectionInfo() as $key => $targets) {
         Database::removeConnection($key);
     }
     parent::tearDown();
 }
开发者ID:scratch,项目名称:gai,代码行数:40,代码来源:KernelTestBase.php


注:本文中的Drupal::unsetContainer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。