Loading core/tests/Drupal/BuildTests/Framework/BuildTestBase.php +7 −0 Changes for core/tests/Drupal/BuildTests/Framework/BuildTestBase.php: 7 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -393,6 +393,10 @@ protected function standUpServer($working_dir = NULL) { * * Test authors should call visit() or assertVisit() instead. * * When initializing the server, if '.ht.router.php' exists in the root, it is * leveraged. If testing with a version of Drupal before 8.5.x., this file * does not exist. * * @param int $port * The port number for the server. * @param string|null $working_dir Loading @@ -415,6 +419,9 @@ protected function instantiateServer($port, $working_dir = NULL) { '-t', $working_path, ]; if (file_exists($working_path . DIRECTORY_SEPARATOR . '.ht.router.php')) { $server[] = $working_path . DIRECTORY_SEPARATOR . '.ht.router.php'; } $ps = new Process($server, $working_path); $ps->setIdleTimeout(30) ->setTimeout(30) Loading core/tests/Drupal/BuildTests/Framework/Tests/HtRouterTest.php 0 → 100644 +28 −0 Changes for core/tests/Drupal/BuildTests/Framework/Tests/HtRouterTest.php: 28 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Drupal\BuildTests\Framework\Tests; use Drupal\BuildTests\QuickStart\QuickStartTestBase; /** * @coversDefaultClass \Drupal\BuildTests\Framework\BuildTestBase * @group Build */ class HtRouterTest extends QuickStartTestBase { /** * @covers ::instantiateServer */ public function testHtRouter() { $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); } } core/tests/Drupal/BuildTests/QuickStart/QuickStartTestBase.php 0 → 100644 +66 −0 Changes for core/tests/Drupal/BuildTests/QuickStart/QuickStartTestBase.php: 66 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Drupal\BuildTests\QuickStart; use Drupal\BuildTests\Framework\BuildTestBase; use Symfony\Component\Process\PhpExecutableFinder; /** * Helper methods for using the quickstart feature of Drupal. */ 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(); } } Loading
core/tests/Drupal/BuildTests/Framework/BuildTestBase.php +7 −0 Changes for core/tests/Drupal/BuildTests/Framework/BuildTestBase.php: 7 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -393,6 +393,10 @@ protected function standUpServer($working_dir = NULL) { * * Test authors should call visit() or assertVisit() instead. * * When initializing the server, if '.ht.router.php' exists in the root, it is * leveraged. If testing with a version of Drupal before 8.5.x., this file * does not exist. * * @param int $port * The port number for the server. * @param string|null $working_dir Loading @@ -415,6 +419,9 @@ protected function instantiateServer($port, $working_dir = NULL) { '-t', $working_path, ]; if (file_exists($working_path . DIRECTORY_SEPARATOR . '.ht.router.php')) { $server[] = $working_path . DIRECTORY_SEPARATOR . '.ht.router.php'; } $ps = new Process($server, $working_path); $ps->setIdleTimeout(30) ->setTimeout(30) Loading
core/tests/Drupal/BuildTests/Framework/Tests/HtRouterTest.php 0 → 100644 +28 −0 Changes for core/tests/Drupal/BuildTests/Framework/Tests/HtRouterTest.php: 28 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Drupal\BuildTests\Framework\Tests; use Drupal\BuildTests\QuickStart\QuickStartTestBase; /** * @coversDefaultClass \Drupal\BuildTests\Framework\BuildTestBase * @group Build */ class HtRouterTest extends QuickStartTestBase { /** * @covers ::instantiateServer */ public function testHtRouter() { $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); } }
core/tests/Drupal/BuildTests/QuickStart/QuickStartTestBase.php 0 → 100644 +66 −0 Changes for core/tests/Drupal/BuildTests/QuickStart/QuickStartTestBase.php: 66 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Drupal\BuildTests\QuickStart; use Drupal\BuildTests\Framework\BuildTestBase; use Symfony\Component\Process\PhpExecutableFinder; /** * Helper methods for using the quickstart feature of Drupal. */ 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(); } }