class QuickStartTestBase
Same name in other branches
- 9 core/tests/Drupal/BuildTests/QuickStart/QuickStartTestBase.php \Drupal\BuildTests\QuickStart\QuickStartTestBase
- 8.9.x core/tests/Drupal/BuildTests/QuickStart/QuickStartTestBase.php \Drupal\BuildTests\QuickStart\QuickStartTestBase
- 11.x core/tests/Drupal/BuildTests/QuickStart/QuickStartTestBase.php \Drupal\BuildTests\QuickStart\QuickStartTestBase
Helper methods for using the quickstart feature of Drupal.
Hierarchy
- class \Drupal\BuildTests\Framework\BuildTestBase extends \PHPUnit\Framework\TestCase uses \Drupal\TestTools\Extension\RequiresComposerTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait
- class \Drupal\BuildTests\QuickStart\QuickStartTestBase extends \Drupal\BuildTests\Framework\BuildTestBase
Expanded class hierarchy of QuickStartTestBase
3 files declare their use of QuickStartTestBase
- GenerateThemeTest.php in core/
tests/ Drupal/ Tests/ Core/ Command/ GenerateThemeTest.php - GenerateThemeTest.php in core/
tests/ Drupal/ BuildTests/ Command/ GenerateThemeTest.php - HtRouterTest.php in core/
tests/ Drupal/ BuildTests/ Framework/ Tests/ HtRouterTest.php
File
-
core/
tests/ Drupal/ BuildTests/ QuickStart/ QuickStartTestBase.php, line 13
Namespace
Drupal\BuildTests\QuickStartView source
abstract class QuickStartTestBase extends BuildTestBase {
/**
* User name of the admin account generated during install.
*
* @var string
*/
protected $adminUsername;
/**
* Password of the admin account generated during install.
*
* @var string
*/
protected $adminPassword;
/**
* Install a Drupal site using the quick start feature.
*
* @param string $profile
* Drupal profile to install.
* @param string $working_dir
* (optional) A working directory relative to the workspace, within which to
* execute the command. Defaults to the workspace directory.
*/
public function installQuickStart($profile, $working_dir = NULL) {
$php_finder = new PhpExecutableFinder();
$install_process = $this->executeCommand($php_finder->find() . ' ./core/scripts/drupal install ' . $profile, $working_dir);
$this->assertCommandOutputContains('Username:');
preg_match('/Username: (.+)\\vPassword: (.+)/', $install_process->getOutput(), $matches);
$this->assertNotEmpty($this->adminUsername = $matches[1]);
$this->assertNotEmpty($this->adminPassword = $matches[2]);
}
/**
* Helper that uses Drupal's user/login form to log in.
*
* @param string $username
* Username.
* @param string $password
* Password.
* @param string $working_dir
* (optional) A working directory within which to login. Defaults to the
* workspace directory.
*/
public function formLogin($username, $password, $working_dir = NULL) {
$this->visit('/user/login', $working_dir);
$assert = $this->getMink()
->assertSession();
$assert->statusCodeEquals(200);
$assert->fieldExists('edit-name')
->setValue($username);
$assert->fieldExists('edit-pass')
->setValue($password);
$session = $this->getMink()
->getSession();
$session->getPage()
->findButton('Log in')
->submit();
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overrides |
---|---|---|---|---|
BuildTestBase::$commandProcess | private | property | The most recent command process. | |
BuildTestBase::$destroyBuild | protected | property | Default to destroying build artifacts after a test finishes. | |
BuildTestBase::$hostName | private static | property | Our native host name, used by PHP when it starts up the server. | |
BuildTestBase::$hostPort | private | property | Port that will be tested. | |
BuildTestBase::$mink | private | property | The Mink session manager. | |
BuildTestBase::$phpFinder | private | property | The PHP executable finder. | |
BuildTestBase::$portLocks | private | property | A list of ports used by the test. | |
BuildTestBase::$serverDocroot | private | property | The docroot for the server process. | |
BuildTestBase::$serverProcess | private | property | The process that's running the HTTP server. | |
BuildTestBase::$workspaceDir | private | property | The working directory where this test will manipulate files. | |
BuildTestBase::assertCommandExitCode | public | function | Asserts that the last command returned the specified exit code. | |
BuildTestBase::assertCommandOutputContains | public | function | Assert that text is present in the output of the most recent command. | |
BuildTestBase::assertCommandSuccessful | public | function | Asserts that the last command ran without error. | |
BuildTestBase::assertDrupalVisit | public | function | Helper function to assert that the last visit was a Drupal site. | |
BuildTestBase::assertErrorOutputContains | public | function | Assert that text is present in the error output of the most recent command. | |
BuildTestBase::assertErrorOutputNotContains | public | function | Assert text is not present in the error output of the most recent command. | |
BuildTestBase::checkPortIsAvailable | protected | function | Checks whether a port is available. | |
BuildTestBase::copyCodebase | public | function | Copy the current working codebase into a workspace. | |
BuildTestBase::executeCommand | public | function | Run a command. | |
BuildTestBase::findAvailablePort | protected | function | Discover an available port number. | |
BuildTestBase::getCodebaseFinder | public | function | Get a default Finder object for a Drupal codebase. | |
BuildTestBase::getComposerRoot | public | function | Gets the path to the Composer root directory. | |
BuildTestBase::getDrupalRoot | public | function | Get the root path of this Drupal codebase. | |
BuildTestBase::getDrupalRootStatic | public static | function | Get the root path of this Drupal codebase. | |
BuildTestBase::getMink | public | function | Get the Mink instance. | |
BuildTestBase::getPortNumber | protected | function | Get the port number for requests. | |
BuildTestBase::getWorkingPath | protected | function | Get the working directory within the workspace, creating if necessary. | |
BuildTestBase::getWorkingPathDrupalRoot | public | function | Gets the working path for Drupal core. | |
BuildTestBase::getWorkspaceDirectory | public | function | Full path to the workspace where this test can build. | |
BuildTestBase::getWorkspaceDrupalRoot | public | function | Gets the path to Drupal root in the workspace directory. | |
BuildTestBase::initMink | protected | function | Set up the Mink session manager. | |
BuildTestBase::instantiateServer | protected | function | Do the work of making a server process. | |
BuildTestBase::setUp | protected | function | 3 | |
BuildTestBase::standUpServer | protected | function | Makes a local test server using PHP's internal HTTP server. | |
BuildTestBase::stopServer | protected | function | Stop the HTTP server, zero out all necessary variables. | |
BuildTestBase::tearDown | protected | function | 1 | |
BuildTestBase::visit | public | function | Visit a URI on the HTTP server. | |
PhpUnitWarnings::$deprecationWarnings | private static | property | Deprecation warnings from PHPUnit to raise with @trigger_error(). | |
PhpUnitWarnings::addWarning | public | function | Converts PHPUnit deprecation warnings to E_USER_DEPRECATED. | |
QuickStartTestBase::$adminPassword | protected | property | Password of the admin account generated during install. | |
QuickStartTestBase::$adminUsername | protected | property | User name of the admin account generated during install. | |
QuickStartTestBase::formLogin | public | function | Helper that uses Drupal's user/login form to log in. | |
QuickStartTestBase::installQuickStart | public | function | Install a Drupal site using the quick start feature. | |
RequiresComposerTrait::requiresComposer | public static | function | @beforeClass |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.