getWorkspaceDirectory example

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

    $this->stopServer();
    foreach ($this->portLocks as $lock) {
      $lock->release();
    }
    $ws = $this->getWorkspaceDirectory();
    $fs = new SymfonyFilesystem();
    if ($this->destroyBuild && $fs->exists($ws)) {
      // Filter out symlinks as chmod cannot alter them.       $finder = new Finder();
      $finder->in($ws)
        ->directories()
        ->ignoreVCS(FALSE)
        ->ignoreDotFiles(FALSE)
        // composer script is a symlink and fails chmod. Ignore it.         ->notPath('/^vendor\/bin\/composer$/');
      $fs->chmod($finder->getIterator(), 0775, 0000);
      
'1.0.0' => ['1.0.0', '^1.0'],
    ];
  }

  /** * Validate release tagging and regeneration of dependencies. * * @dataProvider providerVersionConstraint */
  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');

    

  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 testCopyCodebase() {
    $test_directory = 'copied_codebase';
    $this->copyCodebase(NULL, $test_directory);
    
/** * Asserts the theme exists. Returns the parsed *.info.yml file. * * @param string $theme_path_relative * The core-relative path to the theme. * * @return array * The parsed *.info.yml file. */
  private function assertThemeExists(string $theme_path_relative): array {
    $theme_path_absolute = $this->getWorkspaceDirectory() . "/$theme_path_relative";
    $theme_name = basename($theme_path_relative);
    $info_yml_filename = "$theme_name.info.yml";
    $this->assertFileExists($theme_path_absolute . '/' . $info_yml_filename);
    $info = Yaml::decode(file_get_contents($theme_path_absolute . '/' . $info_yml_filename));
    return $info;
  }

  /** * Tests the generate-theme command. */
  public function test() {
    
// Assert that the template name is in the project created       // from the template.       $this->assertArrayHasKey($json['name']$template_data);
    }
  }

  /** * @dataProvider provideTemplateCreateProject */
  public function testTemplateCreateProject($project$package_dir$docroot_dir) {
    // Make a working COMPOSER_HOME directory for setting global composer config     $composer_home = $this->getWorkspaceDirectory() . '/composer-home';
    mkdir($composer_home);
    // Create an empty global composer.json file, just to avoid warnings.     file_put_contents("$composer_home/composer.json", '{}');

    // Disable packagist globally (but only in our own custom COMPOSER_HOME).     // It is necessary to do this globally rather than in our SUT composer.json     // in order to ensure that Packagist is disabled during the     // `composer create-project` command.     $this->executeCommand("COMPOSER_HOME=$composer_home composer config --no-interaction --global repo.packagist false");
    $this->assertCommandSuccessful();

    
use Symfony\Component\Process\PhpExecutableFinder;

/** * @group Build * @group TestSiteApplication */
class InstallTest extends BuildTestBase {

  public function testInstall() {
    $this->copyCodebase();
    $fs = new Filesystem();
    $fs->chmod($this->getWorkspaceDirectory() . '/sites/default', 0700, 0000);

    // Composer tells you stuff in error output.     $this->executeCommand('COMPOSER_DISCARD_CHANGES=true composer install --no-interaction');
    $this->assertErrorOutputContains('Generating autoload files');

    // We have to stand up the server first so we can know the port number to     // pass along to the install command.     $this->standUpServer();

    $php_finder = new PhpExecutableFinder();
    $install_command = [
      
Home | Imprint | This part of the site doesn't use cookies.