You are here

class BrowserTestBaseTest in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/tests/src/Functional/BrowserTestBaseTest.php \Drupal\Tests\simpletest\Functional\BrowserTestBaseTest

Tests BrowserTestBase functionality.

@group simpletest

@runTestsInSeparateProcesses @preserveGlobalState disabled

Hierarchy

Expanded class hierarchy of BrowserTestBaseTest

File

core/modules/simpletest/tests/src/Functional/BrowserTestBaseTest.php, line 20
Contains \Drupal\Tests\simpletest\Functional\BrowserTestBaseTest.

Namespace

Drupal\Tests\simpletest\Functional
View source
class BrowserTestBaseTest extends BrowserTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  public static $modules = array(
    'test_page_test',
    'form_test',
  );

  /**
   * Tests basic page test.
   */
  public function testGoTo() {
    $account = $this
      ->drupalCreateUser();
    $this
      ->drupalLogin($account);

    // Visit a Drupal page that requires login.
    $this
      ->drupalGet('test-page');
    $this
      ->assertSession()
      ->statusCodeEquals(200);

    // Test page contains some text.
    $this
      ->assertSession()
      ->pageTextContains('Test page text.');
  }

  /**
   * Tests basic form functionality.
   */
  public function testForm() {

    // Ensure the proper response code for a _form route.
    $this
      ->drupalGet('form-test/object-builder');
    $this
      ->assertSession()
      ->statusCodeEquals(200);

    // Ensure the form and text field exist.
    $this
      ->assertSession()
      ->elementExists('css', 'form#form-test-form-test-object');
    $this
      ->assertSession()
      ->fieldExists('bananas');
    $edit = [
      'bananas' => 'green',
    ];
    $this
      ->submitForm($edit, 'Save', 'form-test-form-test-object');
    $config_factory = $this->container
      ->get('config.factory');
    $value = $config_factory
      ->get('form_test.object')
      ->get('bananas');
    $this
      ->assertSame('green', $value);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BrowserTestBase::$classLoader protected property Class loader.
BrowserTestBase::$configDirectories protected property The config directories used in this test.
BrowserTestBase::$configImporter protected property The config importer that can be used in a test.
BrowserTestBase::$container protected property The dependency injection container used in the test.
BrowserTestBase::$customTranslations protected property An array of custom translations suitable for drupal_rewrite_settings().
BrowserTestBase::$databasePrefix protected property The database prefix of this test run.
BrowserTestBase::$kernel protected property The DrupalKernel instance used in the test.
BrowserTestBase::$loggedInUser protected property The current user logged in using the Mink controlled browser.
BrowserTestBase::$mink protected property Mink session manager.
BrowserTestBase::$minkDefaultDriverArgs protected property
BrowserTestBase::$minkDefaultDriverClass protected property
BrowserTestBase::$originalSiteDirectory protected property The site directory of the original parent site.
BrowserTestBase::$privateFilesDirectory protected property The private file directory for the test environment.
BrowserTestBase::$profile protected property The profile to install as a basis for testing.
BrowserTestBase::$publicFilesDirectory protected property The public file directory for the test environment.
BrowserTestBase::$rootUser protected property The root user.
BrowserTestBase::$siteDirectory protected property The site directory of this test run.
BrowserTestBase::$tempFilesDirectory protected property The temp file directory for the test environment.
BrowserTestBase::$timeLimit protected property Time limit in seconds for the test.
BrowserTestBase::$translationFilesDirectory protected property The translation file directory for the test environment.
BrowserTestBase::assertSession public function Returns WebAssert object.
BrowserTestBase::changeDatabasePrefix private function Changes the database connection to the prefixed one.
BrowserTestBase::checkPermissions protected function Checks whether a given list of permission names is valid.
BrowserTestBase::cleanupEnvironment protected function Clean up the Simpletest environment.
BrowserTestBase::drupalCreateRole protected function Creates a role with specified permissions.
BrowserTestBase::drupalCreateUser protected function Creates a user with a given set of permissions.
BrowserTestBase::drupalGet protected function Retrieves a Drupal path or an absolute path.
BrowserTestBase::drupalLogin protected function Logs in a user using the Mink controlled browser.
BrowserTestBase::drupalLogout protected function Logs a user out of the Mink controlled browser and confirms.
BrowserTestBase::drupalUserIsLoggedIn protected function Returns whether a given user account is logged in.
BrowserTestBase::filePreDeleteCallback public static function Ensures test files are deletable within file_unmanaged_delete_recursive().
BrowserTestBase::getAbsoluteUrl protected function Takes a path and returns an absolute path.
BrowserTestBase::getDatabaseConnection public static function Returns the database connection to the site running Simpletest.
BrowserTestBase::getDefaultDriverInstance protected function Gets an instance of the default Mink driver.
BrowserTestBase::getOptions protected function Helper function to get the options of select field.
BrowserTestBase::getSession public function Returns Mink session.
BrowserTestBase::initMink protected function Initializes Mink sessions.
BrowserTestBase::installDrupal public function Installs Drupal into the Simpletest site.
BrowserTestBase::installParameters protected function Returns the parameters that will be used when Simpletest installs Drupal.
BrowserTestBase::prepareDatabasePrefix private function Generates a database prefix for running tests.
BrowserTestBase::prepareEnvironment protected function Prepares the current environment for running the test.
BrowserTestBase::prepareRequest protected function Prepare for a request to testing site.
BrowserTestBase::prepareRequestForGenerator protected function Creates a mock request and sets it on the generator.
BrowserTestBase::rebuildContainer protected function Rebuilds \Drupal::getContainer().
BrowserTestBase::refreshVariables protected function Refreshes in-memory configuration and state information.
BrowserTestBase::registerSessions protected function Registers additional Mink sessions.
BrowserTestBase::resetAll protected function Resets all data structures after having enabled new modules.
BrowserTestBase::runTest protected function Override to use Mink exceptions.
BrowserTestBase::setUp protected function
BrowserTestBase::submitForm protected function Fills and submits a form.
BrowserTestBase::tearDown protected function
BrowserTestBase::writeSettings protected function Rewrites the settings.php file of the test site.
BrowserTestBaseTest::$modules public static property Modules to enable.
BrowserTestBaseTest::testForm public function Tests basic form functionality.
BrowserTestBaseTest::testGoTo public function Tests basic page test.
RandomGeneratorTrait::$randomGenerator protected property The random generator.
RandomGeneratorTrait::getRandomGenerator protected function Gets the random generator for the utility methods.
RandomGeneratorTrait::randomMachineName protected function Generates a unique random string containing letters and numbers.
RandomGeneratorTrait::randomObject public function Generates a random PHP object.
RandomGeneratorTrait::randomString public function Generates a pseudo-random string of ASCII characters of codes 32 to 126.
RandomGeneratorTrait::randomStringValidate public function Callback for random string validation.
SessionTestTrait::$sessionName protected property The name of the session cookie.
SessionTestTrait::generateSessionName protected function Generates a session cookie name.
SessionTestTrait::getSessionName protected function Returns the session name in use on the child site.