Select Git revision
MigrationInterface.php
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());