diff --git a/core/modules/simpletest/src/BrowserTestBase.php b/core/modules/simpletest/src/BrowserTestBase.php index 2ffdbff..67cfe50 100644 --- a/core/modules/simpletest/src/BrowserTestBase.php +++ b/core/modules/simpletest/src/BrowserTestBase.php @@ -2,7 +2,7 @@ /** * @file - * Definition of \Drupal\simpletest\BrowserTestBase. + * Contains \Drupal\simpletest\BrowserTestBase. */ namespace Drupal\simpletest; @@ -63,14 +63,14 @@ protected $originalSite; /** - * Time limit for the test. + * Time limit in seconds for the test. */ protected $timeLimit = 500; /** * The public file directory for the test environment. * - * This is set in prepareEnvironment(). + * This is set in BrowserTestBase::prepareEnvironment(). * * @var string */ @@ -79,7 +79,7 @@ /** * The private file directory for the test environment. * - * This is set in prepareEnvironment(). + * This is set in BrowserTestBase::prepareEnvironment(). * * @var string */ @@ -88,7 +88,7 @@ /** * The temp file directory for the test environment. * - * This is set in prepareEnvironment(). + * This is set in BrowserTestBase::prepareEnvironment(). * * @var string */ @@ -97,7 +97,7 @@ /** * The translation file directory for the test environment. * - * This is set in prepareEnvironment(). + * This is set in BrowserTestBase::prepareEnvironment(). * * @var string */ @@ -140,6 +140,8 @@ /** * The current session name, if available. + * + * @var string */ protected $session_name = NULL; @@ -450,7 +452,7 @@ protected function getAbsoluteUrl($path) { } /** - * Create a user with a given set of permissions. + * Creates a user with a given set of permissions. * * @param array $permissions * Array of permission names to assign to user. Note that the user always @@ -632,7 +634,7 @@ protected function checkPermissions(array $permissions) { } /** - * Log in a user with the internal browser. + * Logs in a user using the mink browser. * * If a user is already logged in, then the current user is logged out before * logging in the specified user. @@ -669,7 +671,7 @@ protected function drupalLogin(AccountInterface $account) { 'pass' => $account->pass_raw, ), t('Log in')); - // @see WebTestBase::drupalUserIsLoggedIn() + // @see BrowserTestBase::drupalUserIsLoggedIn() $account->session_id = $this->getSession()->getCookie(session_name()); $this->assertTrue($this->drupalUserIsLoggedIn($account), String::format('User %name successfully logged in.', array('name' => $account->getUsername()))); @@ -699,7 +701,7 @@ protected function drupalLogout() { } /** - * Fill and submit a form. + * Fills and submit a form. * * @param array $edit * Field data in an associative array. Changes the current input fields @@ -833,7 +835,7 @@ protected function getRandomGenerator() { } /** - * {@inheritdoc} + * Installs drupal into the simpletest site. */ public function installDrupal() { // Define information about the user 1 account. @@ -1181,10 +1183,10 @@ public static function getDatabaseConnection() { $connection = Database::getConnection('default', 'simpletest_original_default'); } catch (ConnectionNotDefinedException $e) { - error_log('8'); - // If TestBase::prepareEnvironment() or TestBase::restoreEnvironment() - // failed, the test-specific database connection does not exist - // yet/anymore, so fall back to the default of the (UI) test runner. + // If BrowserTestBase::prepareEnvironment() or + // BrowserTestBase::restoreEnvironment() failed, the test-specific + // database connection does not exist yet/anymore, so fall back to the + // default of the (UI) test runner. $connection = Database::getConnection('default', 'default'); } } diff --git a/core/modules/simpletest/src/WebAssert.php b/core/modules/simpletest/src/WebAssert.php index c5b0a71..daea904 100644 --- a/core/modules/simpletest/src/WebAssert.php +++ b/core/modules/simpletest/src/WebAssert.php @@ -7,16 +7,17 @@ namespace Drupal\simpletest; +use Behat\Mink\WebAssert as MinkWebAssert; use Behat\Mink\Element\TraversableElement; use Behat\Mink\Exception\ElementNotFoundException; /** * Defines a class with methods for asserting presence of elements during tests. */ -class WebAssert extends \Behat\Mink\WebAssert { +class WebAssert extends MinkWebAssert { /** - * Checks that specific field exists on the current page. + * Checks that specific button exists on the current page. * * @param string $button * One of id|name|label|value for the button. @@ -41,7 +42,7 @@ public function buttonExists($button, TraversableElement $container = NULL) { } /** - * Checks that specific field exists on the current page. + * Checks that specific select field exists on the current page. * * @param string $select * One of id|name|label|value for the select field. diff --git a/core/modules/simpletest/tests/simpletest_test/config/install/simpletest_test.settings.yml b/core/modules/simpletest/tests/simpletest_example/config/install/simpletest_test.settings.yml similarity index 100% rename from core/modules/simpletest/tests/simpletest_test/config/install/simpletest_test.settings.yml rename to core/modules/simpletest/tests/simpletest_example/config/install/simpletest_test.settings.yml diff --git a/core/modules/simpletest/tests/simpletest_test/config/schema/simpletest_test.schema.yml b/core/modules/simpletest/tests/simpletest_example/config/schema/simpletest_test.schema.yml similarity index 100% rename from core/modules/simpletest/tests/simpletest_test/config/schema/simpletest_test.schema.yml rename to core/modules/simpletest/tests/simpletest_example/config/schema/simpletest_test.schema.yml diff --git a/core/modules/simpletest/tests/simpletest_example/simpletest_example.info.yml b/core/modules/simpletest/tests/simpletest_example/simpletest_example.info.yml new file mode 100644 index 0000000..27a72ba --- /dev/null +++ b/core/modules/simpletest/tests/simpletest_example/simpletest_example.info.yml @@ -0,0 +1,6 @@ +name: Simpletest Example +type: module +description: 'Helper module for BrowserTestBaseTest.' +package: Testing +version: VERSION +core: 8.x diff --git a/core/modules/simpletest/tests/simpletest_example/simpletest_example.permissions.yml b/core/modules/simpletest/tests/simpletest_example/simpletest_example.permissions.yml new file mode 100644 index 0000000..2e5ef16 --- /dev/null +++ b/core/modules/simpletest/tests/simpletest_example/simpletest_example.permissions.yml @@ -0,0 +1,2 @@ +simpletest_example access tests: + title: 'Access simpletest example tests' diff --git a/core/modules/simpletest/tests/simpletest_example/simpletest_example.routing.yml b/core/modules/simpletest/tests/simpletest_example/simpletest_example.routing.yml new file mode 100644 index 0000000..fbf622d --- /dev/null +++ b/core/modules/simpletest/tests/simpletest_example/simpletest_example.routing.yml @@ -0,0 +1,12 @@ +simpletest.settings: + path: '/simpletest/hello' + defaults: + _controller: '\Drupal\simpletest_example\Controller\ExampleController::hello' + requirements: + _permission: 'simpletest_example access tests' +simpletest.example_form: + path: '/simpletest/example-form' + defaults: + _form: '\Drupal\simpletest_example\Form\ExampleForm' + requirements: + _access: 'TRUE' diff --git a/core/modules/simpletest/tests/simpletest_test/src/Controller/SimpletestController.php b/core/modules/simpletest/tests/simpletest_example/src/Controller/ExampleController.php similarity index 62% rename from core/modules/simpletest/tests/simpletest_test/src/Controller/SimpletestController.php rename to core/modules/simpletest/tests/simpletest_example/src/Controller/ExampleController.php index a20da2a..631b917 100644 --- a/core/modules/simpletest/tests/simpletest_test/src/Controller/SimpletestController.php +++ b/core/modules/simpletest/tests/simpletest_example/src/Controller/ExampleController.php @@ -2,17 +2,17 @@ /** * @file - * Contains \Drupal\simpletest_test\Controller\SimpletestController. + * Contains \Drupal\simpletest_example\Controller\ExampleController. */ -namespace Drupal\simpletest_test\Controller; +namespace Drupal\simpletest_example\Controller; use Drupal\Core\Controller\ControllerBase; /** * Defines a test controller for testing \Drupal\simpletest\BrowserTestBase. */ -class SimpletestController extends ControllerBase { +class ExampleController extends ControllerBase { /** * Provides output for testing \Drupal\simpletest\BrowserTestBase. @@ -22,7 +22,7 @@ class SimpletestController extends ControllerBase { */ public function hello() { return array( - '#markup' => $this->t('Hello Amsterdam'), + '#markup' => $this->t('Hello Drupal'), ); } diff --git a/core/modules/simpletest/tests/simpletest_test/src/Form/ExampleForm.php b/core/modules/simpletest/tests/simpletest_example/src/Form/ExampleForm.php similarity index 73% rename from core/modules/simpletest/tests/simpletest_test/src/Form/ExampleForm.php rename to core/modules/simpletest/tests/simpletest_example/src/Form/ExampleForm.php index bb6f95d..1d2cb45 100644 --- a/core/modules/simpletest/tests/simpletest_test/src/Form/ExampleForm.php +++ b/core/modules/simpletest/tests/simpletest_example/src/Form/ExampleForm.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\simpletest_test\Form\ExampleForm. + * Contains \Drupal\simpletest_example\Form\ExampleForm. */ -namespace Drupal\simpletest_test\Form; +namespace Drupal\simpletest_example\Form; use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; @@ -28,7 +28,7 @@ public function getFormId() { public function buildForm(array $form, FormStateInterface $form_state) { $form['name'] = [ '#type' => 'textfield', - '#default_value' => \Drupal::config('simpletest_test.settings')->get('name'), + '#default_value' => \Drupal::config('simpletest_example.settings')->get('name'), ]; return parent::buildForm($form, $form_state); } @@ -39,7 +39,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { public function submitForm(array &$form, FormStateInterface $form_state) { // Normally this config object would be injected but this is a only a test // so...who cares? - \Drupal::config('simpletest_test.settings')->set('name', $form_state->getValue('name'))->save(); + \Drupal::config('simpletest_example.settings')->set('name', $form_state->getValue('name'))->save(); parent::submitForm($form, $form_state); } diff --git a/core/modules/simpletest/tests/simpletest_test/simpletest_test.info.yml b/core/modules/simpletest/tests/simpletest_test/simpletest_test.info.yml deleted file mode 100644 index 15241d1..0000000 --- a/core/modules/simpletest/tests/simpletest_test/simpletest_test.info.yml +++ /dev/null @@ -1,6 +0,0 @@ -name: Testing test -type: module -description: 'Provides dummy classes for use by SimpleTest tests.' -package: Testing -version: VERSION -core: 8.x diff --git a/core/modules/simpletest/tests/simpletest_test/simpletest_test.module b/core/modules/simpletest/tests/simpletest_test/simpletest_test.module deleted file mode 100644 index 651884e..0000000 --- a/core/modules/simpletest/tests/simpletest_test/simpletest_test.module +++ /dev/null @@ -1,6 +0,0 @@ -drupalCreateUser(array('simpletest_test access tests')); + $account = $this->drupalCreateUser(array('simpletest_example access tests')); $this->drupalLogin($account); // Visit a Drupal page that requires login. @@ -36,7 +36,7 @@ public function testGoTo() { $this->assertSession()->statusCodeEquals(200); // Test page contains some text. - $this->assertSession()->pageTextContains('Hello Amsterdam'); + $this->assertSession()->pageTextContains('Hello Drupal'); } /** diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh index fe9cee1..dbdce8e 100644 --- a/core/scripts/run-tests.sh +++ b/core/scripts/run-tests.sh @@ -538,12 +538,6 @@ function simpletest_script_execute_batch($test_classes) { continue; } - // Process phpunit web-tests next as they are faster. - if (is_subclass_of($test_class, 'Drupal\simpletest\BrowserTestBase')) { - simpletest_script_run_phpunit($test_id, $test_class); - continue; - } - // Fork a child process. $command = simpletest_script_command($test_id, $test_class); $process = proc_open($command, array(), $pipes, NULL, NULL, array('bypass_shell' => TRUE));