copyCodebase example

/** * {@inheritdoc} */
  protected function setUp(): void {
    $sqlite = (new \PDO('sqlite::memory:'))->query('select sqlite_version()')->fetch()[0];
    if (version_compare($sqlite, Tasks::SQLITE_MINIMUM_VERSION) < 0) {
      $this->markTestSkipped();
    }
    parent::setUp();
    $php_executable_finder = new PhpExecutableFinder();
    $this->php = $php_executable_finder->find();
    $this->copyCodebase();
    $this->executeCommand('COMPOSER_DISCARD_CHANGES=true composer install --no-dev --no-interaction');
    chdir($this->getWorkingPath());
  }

  /** * Generates PHP process to generate a theme from core's starterkit theme. * * @return \Symfony\Component\Process\Process * The PHP process */
  private function generateThemeFromStarterkit($env = NULL) : Process {
    
'1.0.0-rc1' => ['1.0.0-rc1', '1.0.0-rc1'],
      '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');

    
    $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);
    $full_path = $this->getWorkspaceDirectory() . '/' . $test_directory;
    $files = [
      'autoload.php',
      'composer.json',
      'index.php',
      'README.md',
      '.git',
      '.ht.router.php',
    ];
    foreach ($files as $file) {
      $this->assertFileExists($full_path . '/' . $file);
    }
use Drupal\BuildTests\Framework\BuildTestBase;
use Symfony\Component\Filesystem\Filesystem;
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();

    
    // 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();

    // Create a "Composer"-type repository containing one entry for every     // package in the vendor directory.     $vendor_packages_path = $this->getWorkspaceDirectory() . '/vendor_packages/packages.json';
    $this->makeVendorPackage($vendor_packages_path);

    // Make a copy of the code to alter in the workspace directory.     $this->copyCodebase();

    // Tests are typically run on "-dev" versions, but we want to simulate     // running them on a tagged release at the same stability as specified in     // static::MINIMUM_STABILITY, in order to verify that everything will work     // if/when we make such a release.     $simulated_core_version = \Drupal::VERSION;
    $simulated_core_version_suffix = (static::MINIMUM_STABILITY === 'stable' ? '' : '-' . static::MINIMUM_STABILITY . '99');
    $simulated_core_version = str_replace('-dev', $simulated_core_version_suffix$simulated_core_version);
    Composer::setDrupalVersion($this->getWorkspaceDirectory()$simulated_core_version);
    $this->assertDrupalVersion($simulated_core_version$this->getWorkspaceDirectory());

    
class HtRouterTest extends QuickStartTestBase {

  /** * @covers ::instantiateServer */
  public function testHtRouter() {
    $sqlite = (new \PDO('sqlite::memory:'))->query('select sqlite_version()')->fetch()[0];
    if (version_compare($sqlite, Tasks::SQLITE_MINIMUM_VERSION) < 0) {
      $this->markTestSkipped();
    }

    $this->copyCodebase();
    $this->executeCommand('COMPOSER_DISCARD_CHANGES=true composer install --no-dev --no-interaction');
    $this->assertErrorOutputContains('Generating autoload files');
    $this->installQuickStart('minimal');
    $this->formLogin($this->adminUsername, $this->adminPassword);
    $this->visit('/.well-known/change-password');
    $this->assertDrupalVisit();
    $url = $this->getMink()->getSession()->getCurrentUrl();
    $this->assertEquals('http://localhost:' . $this->getPortNumber() . '/user/1/edit', $url);
  }

}
/** * Test whether components' composer.json can be installed in isolation. * * @dataProvider provideComponentPaths */
  public function testComponentComposerJson(string $component_path): void {
    // Only copy the components. Copy all of them because some of them depend on     // each other.     $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();
  }

  
Home | Imprint | This part of the site doesn't use cookies.