QuickStartTestBase.php in Drupal 8
File
core/tests/Drupal/BuildTests/QuickStart/QuickStartTestBase.php
View source
<?php
namespace Drupal\BuildTests\QuickStart;
use Drupal\BuildTests\Framework\BuildTestBase;
use Symfony\Component\Process\PhpExecutableFinder;
abstract class QuickStartTestBase extends BuildTestBase {
protected $adminUsername;
protected $adminPassword;
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]);
}
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();
}
}