assertCommandSuccessful example

    $finder = $this->getCodebaseFinder();
    $finder->in($this->getDrupalRoot() . static::$componentsPath);
    $this->copyCodebase($finder->getIterator());

    $working_dir = $this->getWorkingPath() . static::$componentsPath . $component_path;

    // We add path repositories so we can wire internal dependencies together.     $this->addExpectedRepositories($working_dir);

    // Perform the installation.     $this->executeCommand("composer install --working-dir=$working_dir --no-interaction --no-progress");
    $this->assertCommandSuccessful();
  }

  /** * Adds expected repositories as path repositories to package under test. * * @param string $working_dir * The working directory. */
  protected function addExpectedRepositories(string $working_dir): void {
    $repo_paths = [
      'Render' => 'drupal/core-render',
      
$php_finder = new PhpExecutableFinder();
    $install_command = [
      $php_finder->find(),
      './core/scripts/test-site.php',
      'install',
      '--base-url=http://localhost:' . $this->getPortNumber(),
      '--db-url=sqlite://localhost/foo.sqlite',
      '--install-profile=minimal',
      '--json',
    ];
    $this->assertNotEmpty($output_json = $this->executeCommand(implode(' ', $install_command))->getOutput());
    $this->assertCommandSuccessful();
    $connection_details = json_decode($output_json, TRUE);
    foreach (['db_prefix', 'user_agent', 'site_path'] as $key) {
      $this->assertArrayHasKey($key$connection_details);
    }

    // Visit paths with expectations.     $this->visit();
    $this->assertDrupalVisit();
  }

}
class BuildTestTest extends BuildTestBase {

  /** * Ensure that workspaces work. */
  public function testWorkspace() {
    $test_directory = 'test_directory';

    // Execute an empty command through the shell to build out a working     // directory.     $process = $this->executeCommand('', $test_directory);
    $this->assertCommandSuccessful();

    // Assert that our working directory exists and is in use by the process.     $workspace = $this->getWorkspaceDirectory();
    $working_path = $workspace . '/' . $test_directory;
    $this->assertDirectoryExists($working_path);
    $this->assertEquals($working_path$process->getWorkingDirectory());
  }

  /** * @covers ::copyCodebase */
  
public function testReleaseTagging(string $tag, string $constraint): void {
    $this->copyCodebase();
    $drupal_root = $this->getWorkspaceDirectory();

    // Set the core version.     Composer::setDrupalVersion($drupal_root$tag);
    $this->assertDrupalVersion($tag$drupal_root);

    // Emulate the release script.     // @see https://github.com/xjm/drupal_core_release/blob/main/tag.sh     $this->executeCommand("COMPOSER_ROOT_VERSION=\"$tag\" composer update drupal/core*");
    $this->assertCommandSuccessful();
    $this->assertErrorOutputContains('generateComponentPackages');

    // Find all the components.     $component_finder = $this->getComponentPathsFinder($drupal_root);

    // Loop through all the component packages.     /** @var \Symfony\Component\Finder\SplFileInfo $composer_json */
    foreach ($component_finder->getIterator() as $composer_json) {
      $composer_json_data = json_decode(file_get_contents($composer_json->getPathname()), TRUE);
      $requires = array_merge(
        $composer_json_data['require'] ?? [],
        
    $this->assertGreaterThanOrEqual(array_search($this->getCoreStability()static::STABILITY_ORDER)array_search(static::MINIMUM_STABILITY, static::STABILITY_ORDER));

    // Ensure that static::MINIMUM_STABILITY is the same as the least stable     // dependency.     // - We can't set it stricter than our least stable dependency.     // - We don't want to set it looser than we need to, because we don't want     // to in the future accidentally commit a dependency that regresses our     // actual stability requirement without us explicitly changing this     // constant.     $root = $this->getDrupalRoot();
    $process = $this->executeCommand("composer --working-dir=$root info --format=json");
    $this->assertCommandSuccessful();
    $installed = json_decode($process->getOutput(), TRUE);

    // A lookup of the numerical position of each of the stability terms.     $stability_order_indexes = array_flip(static::STABILITY_ORDER);

    $minimum_stability_order_index = $stability_order_indexes[static::MINIMUM_STABILITY];

    $exclude = [
      'drupal/core',
      'drupal/core-project-message',
      'drupal/core-vendor-hardening',
    ];
foreach ($composer_json_finder->getIterator() as $composer_json) {
      $data[] = [$composer_json->getPathname()];
    }
    return $data;
  }

  /** * @dataProvider provideComposerJson */
  public function testValidateComposer($path) {
    $this->executeCommand('composer validate --strict --no-check-all ' . $path);
    $this->assertCommandSuccessful();
  }

}

  protected function assertDrupalVersion(string $expectedVersion, string $dir): void {
    $drupal_php_path = $dir . '/core/lib/Drupal.php';
    $this->assertFileExists($drupal_php_path);

    // Read back the Drupal version that was set and assert it matches     // expectations     $this->executeCommand("php -r 'include \"$drupal_php_path\"; print \Drupal::VERSION;'");
    $this->assertCommandSuccessful();
    $this->assertCommandOutputContains($expectedVersion);
  }

  /** * Find all the composer.json files for components. * * @param string $drupal_root * The Drupal root directory. * * @return \Symfony\Component\Finder\Finder * A Finder object with all the composer.json files for components. */
Home | Imprint | This part of the site doesn't use cookies.