Skip to content
Snippets Groups Projects
Select Git revision
  • 11.x
  • 11.2.x protected
  • 10.5.x protected
  • 10.6.x protected
  • 11.1.x protected
  • 10.4.x protected
  • 11.0.x protected
  • 10.3.x protected
  • 7.x protected
  • 10.2.x protected
  • 10.1.x protected
  • 9.5.x protected
  • 10.0.x protected
  • 9.4.x protected
  • 9.3.x protected
  • 9.2.x protected
  • 9.1.x protected
  • 8.9.x protected
  • 9.0.x protected
  • 8.8.x protected
  • 10.5.2 protected
  • 11.2.3 protected
  • 10.5.1 protected
  • 11.2.2 protected
  • 11.2.1 protected
  • 11.2.0 protected
  • 10.5.0 protected
  • 11.2.0-rc2 protected
  • 10.5.0-rc1 protected
  • 11.2.0-rc1 protected
  • 10.4.8 protected
  • 11.1.8 protected
  • 10.5.0-beta1 protected
  • 11.2.0-beta1 protected
  • 11.2.0-alpha1 protected
  • 10.4.7 protected
  • 11.1.7 protected
  • 10.4.6 protected
  • 11.1.6 protected
  • 10.3.14 protected
40 results

MigrationInterface.php

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    TestSiteApplicationTest.php 13.58 KiB
    <?php
    
    declare(strict_types=1);
    
    namespace Drupal\KernelTests\Scripts;
    
    use Drupal\Component\FileSystem\FileSystem;
    use Drupal\Core\Database\Database;
    use Drupal\Core\Test\TestDatabase;
    use Drupal\KernelTests\KernelTestBase;
    use GuzzleHttp\Client;
    use GuzzleHttp\Psr7\Request;
    use Symfony\Component\Process\PhpExecutableFinder;
    use Symfony\Component\Process\Process;
    
    // cspell:ignore htkey
    
    /**
     * Tests core/scripts/test-site.php.
     *
     * This test uses the Drupal\Core\Database\Database class which has a static,
     * and the CI database services. Therefore it is defined as KernelTest so that
     * it can also run in a separate process to avoid side effects.
     *
     * @see \Drupal\TestSite\TestSiteApplication
     * @see \Drupal\TestSite\Commands\TestSiteInstallCommand
     * @see \Drupal\TestSite\Commands\TestSiteTearDownCommand
     *
     * @group Setup
     * @group #slow
     * @preserveGlobalState disabled
     */
    class TestSiteApplicationTest extends KernelTestBase {
    
      /**
       * The PHP executable path.
       *
       * @var string
       */
      protected $php;
    
      /**
       * {@inheritdoc}
       */
      protected function setUp(): void {
        parent::setUp();
        $php_executable_finder = new PhpExecutableFinder();
        $this->php = $php_executable_finder->find();
      }
    
      /**
       * @coversNothing
       */
      public function testInstallWithNonExistingFile(): void {
        $command_line = $this->php . ' core/scripts/test-site.php install --setup-file "this-class-does-not-exist" --db-url "' . getenv('SIMPLETEST_DB') . '"';
        $process = Process::fromShellCommandline($command_line, $this->root);
        $process->run();
    
        $this->assertStringContainsString('The file this-class-does-not-exist does not exist.', $process->getErrorOutput());
      }
    
      /**
       * @coversNothing
       */
      public function testInstallWithFileWithNoClass(): void {
        $command_line = $this->php . ' core/scripts/test-site.php install --setup-file core/tests/fixtures/empty_file.php.module --db-url "' . getenv('SIMPLETEST_DB') . '"';
        $process = Process::fromShellCommandline($command_line, $this->root);
        $process->run();
    
        $this->assertStringContainsString('The file core/tests/fixtures/empty_file.php.module does not contain a class', $process->getErrorOutput());