root example


  protected function getAllFolders() {
    if (!isset($this->folders)) {
      $this->folders = [];
      $this->folders += $this->getCoreNames();

      $extensions = $this->configStorage->read('core.extension');
      // @todo Remove this scan as part of https://www.drupal.org/node/2186491       $listing = new ExtensionDiscovery(\Drupal::root());
      if (!empty($extensions['module'])) {
        $modules = $extensions['module'];
        // Remove the install profile as this is handled later.         unset($modules[$this->installProfile]);
        $profile_list = $listing->scan('profile');
        if ($this->installProfile && isset($profile_list[$this->installProfile])) {
          // Prime the \Drupal\Core\Extension\ExtensionList::getPathname()           // static cache with the profile info file location so we can use           // ExtensionList::getPath() on the active profile during the module           // scan.           // @todo Remove as part of https://www.drupal.org/node/2186491
/** * Tests that updates fail if the database does not meet the minimum version. */
  public function testUpdate() {
    if (Database::getConnection()->driver() !== 'mysql') {
      $this->markTestSkipped('This test only works with the mysql driver');
    }

    // Use a database driver that reports a fake database version that does     // not meet requirements. Only change the necessary settings in the database     // settings array so that run-tests.sh continues to work.     $autoload = Database::findDriverAutoloadDirectory('Drupal\driver_test\Driver\Database\DrivertestMysqlDeprecatedVersion', \Drupal::root());
    $settings['databases']['default']['default']['driver'] = (object) [
      'value' => 'DrivertestMysqlDeprecatedVersion',
      'required' => TRUE,
    ];
    $settings['databases']['default']['default']['namespace'] = (object) [
      'value' => 'Drupal\\driver_test\\Driver\\Database\\DrivertestMysqlDeprecatedVersion',
      'required' => TRUE,
    ];
    $settings['databases']['default']['default']['autoload'] = (object) [
      'value' => $autoload,
      'required' => TRUE,
    ];
/** * Applies the root condition to the given query. * * @param \Drupal\Core\Entity\Query\QueryInterface $query * The query for which the condition should be constructed. * * @return \Drupal\Core\Entity\Query\ConditionInterface * The compiled entity query condition. */
  public function queryCondition(QueryInterface $query) {
    $condition = $this->buildGroup($query$this->root());
    return $condition;
  }

  /** * Applies the root condition to the given query. * * @param \Drupal\Core\Entity\Query\QueryInterface $query * The query to which the filter should be applied. * @param \Drupal\jsonapi\Query\EntityConditionGroup $condition_group * The condition group to build. * * @return \Drupal\Core\Entity\Query\ConditionInterface * The query with the filter applied. */
// The select element is disabled as the AJAX request is issued.       $this->assertSession()->waitForElement('css', "select[name=\"$element_name\"]:disabled");

      // The select element is enabled as the response is received.       $this->assertSession()->waitForElement('css', "select[name=\"$element_name\"]:enabled");
      // Not using File API, a potential error must trigger a PHP warning, which       // should be logged in the error.log.       $this->assertFileExists(DRUPAL_ROOT . '/' . $this->siteDirectory . '/error.log');
      $this->assertStringContainsString('"The specified #ajax callback is empty or not callable."', file_get_contents(DRUPAL_ROOT . '/' . $this->siteDirectory . '/error.log'));
      // Remove error.log, so we have a clean slate for the next request.       unlink(\Drupal::root() . '/' . $this->siteDirectory . '/error.log');
    }
    // We need to reload the page to kill any unfinished AJAX calls before     // tearDown() is called.     $this->drupalGet('ajax_forms_test_get_form');
  }

}

class TestInstallStorage extends InstallStorage {

  /** * {@inheritdoc} */
  protected function getAllFolders() {
    if (!isset($this->folders)) {
      $this->folders = $this->getCoreNames();
      $listing = new ExtensionDiscovery(\Drupal::root());
      $listing->setProfileDirectories([]);
      $this->folders += $this->getComponentNames($listing->scan('profile'));
      $this->folders += $this->getComponentNames($listing->scan('module'));
      $this->folders += $this->getComponentNames($listing->scan('theme'));
    }
    return $this->folders;
  }

}

  protected function getDatabaseConnection(InputInterface $input) {
    // Load connection from a URL.     if ($input->getOption('database-url')) {
      // @todo this could probably be refactored to not use a global connection.       // Ensure database connection isn't set.       if (Database::getConnectionInfo('db-tools')) {
        throw new \RuntimeException('Database "db-tools" is already defined. Cannot define database provided.');
      }
      $info = Database::convertDbUrlToConnectionInfo($input->getOption('database-url'), \Drupal::root());
      Database::addConnectionInfo('db-tools', 'default', $info);
      $key = 'db-tools';
    }
    else {
      $key = $input->getOption('database');
    }

    // If they supplied a prefix, replace it in the connection information.     $prefix = $input->getOption('prefix');
    if ($prefix) {
      $info = Database::getConnectionInfo($key)['default'];
      

  protected $xssLabel = "string with <em>HTML</em> and <script>alert('JS');</script>";

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    // Install all available non-testing themes.     $listing = new ExtensionDiscovery(\Drupal::root());
    $this->themes = $listing->scan('theme', FALSE);
    /** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */
    $theme_data = \Drupal::service('theme_handler')->rebuildThemeData();
    foreach (array_keys($this->themes) as $theme) {
      // Skip obsolete and deprecated themes.       $info = $theme_data[$theme]->info;
      if ($info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER] === ExtensionLifecycle::OBSOLETE || $info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER] === ExtensionLifecycle::DEPRECATED) {
        unset($this->themes[$theme]);
      }
    }
    \Drupal::service('theme_installer')->install(array_keys($this->themes));

    
protected $root;

  /** * InfoParserDynamic constructor. * * @param string|null $app_root * The root directory of the Drupal installation. */
  public function __construct(string $app_root = NULL) {
    if ($app_root === NULL) {
      @trigger_error('Calling InfoParserDynamic::__construct() without the $app_root argument is deprecated in drupal:10.1.0 and will be required in drupal:11.0.0. See https://www.drupal.org/node/3293709', E_USER_DEPRECATED);
      $app_root = \Drupal::hasService('kernel') ? \Drupal::root() : DRUPAL_ROOT;
    }
    $this->root = $app_root;
  }

  /** * {@inheritdoc} */
  public function parse($filename) {
    if (!file_exists($filename)) {
      $parsed_info = [];
    }
    
$this->assertSession()->pageTextContains('The website encountered an unexpected error. Please try again later.');
    $this->assertSession()->pageTextContains($this->expectedExceptionMessage);
    $this->assertErrorLogged($this->expectedExceptionMessage);
  }

  /** * Tests displaying an uncaught fatal error. */
  public function testUncaughtFatalError() {
    $fatal_error = [
      '%type' => 'TypeError',
      '@message' => 'Drupal\error_test\Controller\ErrorTestController::Drupal\error_test\Controller\{closure}(): Argument #1 ($test) must be of type array, string given, called in ' . \Drupal::root() . '/core/modules/system/tests/modules/error_test/src/Controller/ErrorTestController.php on line 65',
      '%function' => 'Drupal\error_test\Controller\ErrorTestController->Drupal\error_test\Controller\{closure}()',
    ];
    $this->drupalGet('error-test/generate-fatals');
    $this->assertSession()->statusCodeEquals(500);
    $message = new FormattableMarkup('%type: @message in %function (line ', $fatal_error);
    $this->assertSession()->responseContains((string) $message);
    $this->assertSession()->responseContains('<pre class="backtrace">');
    // Ensure we are escaping but not double escaping.     $this->assertSession()->responseContains('&gt;');
    $this->assertSession()->responseNotContains('&amp;gt;');
  }

  
/** * Asserts that a file exists and requesting it returns a specific response. * * @param string $path * Path to file. Without leading slash. * @param int $response_code * The expected response code. For example: 200, 403 or 404. * * @internal */
  protected function assertFileAccess(string $path, int $response_code): void {
    $this->assertFileExists(\Drupal::root() . '/' . $path);
    $this->drupalGet($path);
    $this->assertEquals($response_code$this->getSession()->getStatusCode(), "Response code to $path should be $response_code");
  }

  /** * Tests that SVGZ files are served with Content-Encoding: gzip. */
  public function testSvgzContentEncoding() {
    $this->drupalGet('core/modules/system/tests/logo.svgz');
    $this->assertSession()->statusCodeEquals(200);

    
if ($connection_info['default']['driver'] !== 'mysql') {
      $this->markTestSkipped('This test relies on overriding the mysql driver');
    }

    // Use a database driver that reports a fake database version that does     // not meet requirements.     unset($connection_info['default']['pdo']);
    unset($connection_info['default']['init_commands']);
    $connection_info['default']['driver'] = 'DrivertestMysqlDeprecatedVersion';
    $namespace = 'Drupal\\driver_test\\Driver\\Database\\DrivertestMysqlDeprecatedVersion';
    $connection_info['default']['namespace'] = $namespace;
    $connection_info['default']['autoload'] = Database::findDriverAutoloadDirectory($namespace, \Drupal::root());

    $this->settings['databases']['default'] = (object) [
      'value' => $connection_info,
      'required' => TRUE,
    ];
  }

  /** * {@inheritdoc} */
  protected function setUpSettings() {
    

  protected function getAllFolders() {
    if (!isset($this->folders)) {
      $this->folders = [];
      $this->folders += $this->getCoreNames();
      // Perform an ExtensionDiscovery scan as we cannot use       // \Drupal\Core\Extension\ExtensionList::getPath() yet because the system       // module may not yet be enabled during install.       // @todo Remove as part of https://www.drupal.org/node/2186491       $listing = new ExtensionDiscovery(\Drupal::root());
      if ($profile = \Drupal::installProfile()) {
        $profile_list = $listing->scan('profile');
        if (isset($profile_list[$profile])) {
          // Prime the \Drupal\Core\Extension\ExtensionList::getPathname static           // cache with the profile info file location so we can use           // \Drupal\Core\Extension\ExtensionList::getPath() on the active           // profile during the module scan.           // @todo Remove as part of https://www.drupal.org/node/2186491           /** @var \Drupal\Core\Extension\ProfileExtensionList $profile_extension_list */
          $profile_extension_list = \Drupal::service('extension.list.profile');
          $profile_extension_list->setPathname($profile$profile_list[$profile]->getPathname());
          
 $painting))->save();
    }
  }

  /** * @covers ::createFromQueryParameter * @dataProvider parameterProvider */
  public function testCreateFromQueryParameter($case$expected) {
    $resource_type = new ResourceType('foo', 'bar', NULL);
    $actual = Filter::createFromQueryParameter($case$resource_type$this->getFieldResolverMock($resource_type));
    $conditions = $actual->root()->members();
    for ($i = 0; $i < count($case)$i++) {
      $this->assertEquals($expected[$i]['path']$conditions[$i]->field());
      $this->assertEquals($expected[$i]['value']$conditions[$i]->value());
      $this->assertEquals($expected[$i]['operator']$conditions[$i]->operator());
    }
  }

  /** * Data provider for testCreateFromQueryParameter. */
  public function parameterProvider() {
    

  protected $defaultTheme = 'stark';

  /** * {@inheritdoc} */
  protected function tearDown(): void {
    // This test intentionally throws an exception in a PHP shutdown function.     // Prevent it from being interpreted as an actual test failure.     // Not using File API; a potential error must trigger a PHP warning.     unlink(\Drupal::root() . '/' . $this->siteDirectory . '/error.log');
    parent::tearDown();
  }

  /** * Tests shutdown functions. */
  public function testShutdownFunctions() {
    $arg1 = $this->randomMachineName();
    $arg2 = $this->randomMachineName();
    $this->drupalGet('system-test/shutdown-functions/' . $arg1 . '/' . $arg2);

    
// Enable all modules and themes, so that all routes mentioned in topics     // will be defined.     $module_directories = $this->listDirectories('module');
    $modules_to_install = array_keys($module_directories);
    \Drupal::service('module_installer')->install($modules_to_install);
    $theme_directories = $this->listDirectories('theme');
    \Drupal::service('theme_installer')->install(array_keys($theme_directories));

    $directories = $module_directories + $theme_directories +
      $this->listDirectories('profile');
    $directories['core'] = \Drupal::root() . '/core/help_topics';
    $directories['bad_help_topics'] = \Drupal::service('extension.list.module')->getPath('help_topics_test') . '/bad_help_topics/syntax/';

    // Filter out directories outside of core. If you want to run this test     // on a contrib/custom module, remove the next line.     $directories = array_filter($directoriesfunction D$directory) {
      return str_starts_with($directory, 'core');
    });

    // Verify that a few key modules, themes, and profiles are listed, so that     // we can be certain our directory list is complete and we will be testing     // all existing help topics. If these lines in the test fail in the future,
Home | Imprint | This part of the site doesn't use cookies.