summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwebchick2015-01-06 11:22:03 -0800
committerwebchick2015-01-06 11:22:03 -0800
commitb45af923af04f363bfdfaaef77c08d78f17df9e2 (patch)
treea12adeb0ea91097a196f1c7c3c3654ebb821441e
parent41cb239158b1a51b63830478c24ab0b6e75d21f4 (diff)
Issue #2382195 by tibbsa, subhojit777, tadityar, cilefen, Mile23: Clean-up simpletest module test members - ensure property definition and use of camelCase naming convention
-rw-r--r--core/modules/block/src/Tests/BlockHtmlTest.php2
-rw-r--r--core/modules/config/src/Tests/ConfigExportImportUITest.php2
-rw-r--r--core/modules/field_ui/src/Tests/FieldUIRouteTest.php2
-rw-r--r--core/modules/language/src/Tests/LanguageConfigOverrideImportTest.php2
-rw-r--r--core/modules/locale/src/Tests/LocaleLocaleLookupTest.php2
-rw-r--r--core/modules/node/src/Tests/NodeAccessViewGrantsCacheContextTest.php2
-rw-r--r--core/modules/node/src/Tests/Views/FrontPageTest.php2
-rw-r--r--core/modules/rdf/src/Tests/StandardProfileTest.php2
-rw-r--r--core/modules/shortcut/src/Tests/ShortcutLinksTest.php6
-rw-r--r--core/modules/simpletest/src/InstallerTestBase.php2
-rw-r--r--core/modules/simpletest/src/KernelTestBase.php4
-rw-r--r--core/modules/simpletest/src/TestBase.php157
-rw-r--r--core/modules/simpletest/src/Tests/BrokenSetUpTest.php2
-rw-r--r--core/modules/simpletest/src/Tests/InstallationProfileModuleTestsTest.php11
-rw-r--r--core/modules/simpletest/src/Tests/OtherInstallationProfileTestsTest.php11
-rw-r--r--core/modules/simpletest/src/Tests/SimpleTestTest.php32
-rw-r--r--core/modules/simpletest/src/WebTestBase.php88
-rw-r--r--core/modules/system/src/Tests/DrupalKernel/DrupalKernelTest.php2
-rw-r--r--core/modules/system/src/Tests/File/ConfigTest.php2
-rw-r--r--core/modules/system/src/Tests/File/HtaccessUnitTest.php4
-rw-r--r--core/modules/system/src/Tests/Image/ToolkitGdTest.php2
-rw-r--r--core/modules/system/src/Tests/Installer/DistributionProfileTest.php2
-rw-r--r--core/modules/system/src/Tests/Installer/InstallerTest.php2
-rw-r--r--core/modules/system/src/Tests/Installer/SingleVisibleProfileTest.php2
-rw-r--r--core/modules/system/src/Tests/Session/SessionTest.php4
-rw-r--r--core/modules/system/src/Tests/System/DateFormatsLockedTest.php2
-rw-r--r--core/modules/system/src/Tests/Update/UpdateScriptTest.php2
27 files changed, 246 insertions, 107 deletions
diff --git a/core/modules/block/src/Tests/BlockHtmlTest.php b/core/modules/block/src/Tests/BlockHtmlTest.php
index f9480c4..fe6cce7 100644
--- a/core/modules/block/src/Tests/BlockHtmlTest.php
+++ b/core/modules/block/src/Tests/BlockHtmlTest.php
@@ -26,7 +26,7 @@ class BlockHtmlTest extends WebTestBase {
protected function setUp() {
parent::setUp();
- $this->drupalLogin($this->root_user);
+ $this->drupalLogin($this->rootUser);
// Enable the test_html block, to test HTML ID and attributes.
\Drupal::state()->set('block_test.attributes', array('data-custom-attribute' => 'foo'));
diff --git a/core/modules/config/src/Tests/ConfigExportImportUITest.php b/core/modules/config/src/Tests/ConfigExportImportUITest.php
index 3139d1d..8b1276a 100644
--- a/core/modules/config/src/Tests/ConfigExportImportUITest.php
+++ b/core/modules/config/src/Tests/ConfigExportImportUITest.php
@@ -46,7 +46,7 @@ class ConfigExportImportUITest extends WebTestBase {
// roles are created then the role is lost after import. If the roles
// created have the same name then the sync will fail because they will
// have different UUIDs.
- $this->drupalLogin($this->root_user);
+ $this->drupalLogin($this->rootUser);
}
/**
diff --git a/core/modules/field_ui/src/Tests/FieldUIRouteTest.php b/core/modules/field_ui/src/Tests/FieldUIRouteTest.php
index f88d7a2..b97bc83 100644
--- a/core/modules/field_ui/src/Tests/FieldUIRouteTest.php
+++ b/core/modules/field_ui/src/Tests/FieldUIRouteTest.php
@@ -27,7 +27,7 @@ class FieldUIRouteTest extends WebTestBase {
protected function setUp() {
parent::setUp();
- $this->drupalLogin($this->root_user);
+ $this->drupalLogin($this->rootUser);
}
/**
diff --git a/core/modules/language/src/Tests/LanguageConfigOverrideImportTest.php b/core/modules/language/src/Tests/LanguageConfigOverrideImportTest.php
index cedfb96..537584d 100644
--- a/core/modules/language/src/Tests/LanguageConfigOverrideImportTest.php
+++ b/core/modules/language/src/Tests/LanguageConfigOverrideImportTest.php
@@ -56,7 +56,7 @@ class LanguageConfigOverrideImportTest extends WebTestBase {
$this->drupalGet('fr');
$this->assertText('FR default site name');
- $this->drupalLogin($this->root_user);
+ $this->drupalLogin($this->rootUser);
$this->drupalGet('admin/config/development/maintenance/translate/fr/edit');
$this->assertText('FR message: @site is currently under maintenance. We should be back shortly. Thank you for your patience');
}
diff --git a/core/modules/locale/src/Tests/LocaleLocaleLookupTest.php b/core/modules/locale/src/Tests/LocaleLocaleLookupTest.php
index 66f35e6..0522010 100644
--- a/core/modules/locale/src/Tests/LocaleLocaleLookupTest.php
+++ b/core/modules/locale/src/Tests/LocaleLocaleLookupTest.php
@@ -34,7 +34,7 @@ class LocaleLocaleLookupTest extends WebTestBase {
ConfigurableLanguage::createFromLangcode('fr')->save();
$this->config('system.site')->set('langcode', 'fr')->save();
- $this->drupalLogin($this->root_user);
+ $this->drupalLogin($this->rootUser);
}
/**
diff --git a/core/modules/node/src/Tests/NodeAccessViewGrantsCacheContextTest.php b/core/modules/node/src/Tests/NodeAccessViewGrantsCacheContextTest.php
index 419e6af..1cd8062 100644
--- a/core/modules/node/src/Tests/NodeAccessViewGrantsCacheContextTest.php
+++ b/core/modules/node/src/Tests/NodeAccessViewGrantsCacheContextTest.php
@@ -53,7 +53,7 @@ class NodeAccessViewGrantsCacheContextTest extends NodeTestBase {
$this->noAccessUser2 = $this->drupalCreateUser(array('access content overview', 'access content'));
$this->userMapping = [
- 1 => $this->root_user,
+ 1 => $this->rootUser,
2 => $this->accessUser,
3 => $this->noAccessUser,
];
diff --git a/core/modules/node/src/Tests/Views/FrontPageTest.php b/core/modules/node/src/Tests/Views/FrontPageTest.php
index 34ff389..eb970d6 100644
--- a/core/modules/node/src/Tests/Views/FrontPageTest.php
+++ b/core/modules/node/src/Tests/Views/FrontPageTest.php
@@ -165,7 +165,7 @@ class FrontPageTest extends ViewTestBase {
// contextual links to the homepage view. This verifies there are no errors.
\Drupal::service('module_installer')->install(array('views_ui'));
// Login root user with sufficient permissions.
- $this->drupalLogin($this->root_user);
+ $this->drupalLogin($this->rootUser);
// Test frontpage view.
$this->drupalGet('node');
$this->assertResponse(200);
diff --git a/core/modules/rdf/src/Tests/StandardProfileTest.php b/core/modules/rdf/src/Tests/StandardProfileTest.php
index 092cd5d..40b58fb 100644
--- a/core/modules/rdf/src/Tests/StandardProfileTest.php
+++ b/core/modules/rdf/src/Tests/StandardProfileTest.php
@@ -290,7 +290,7 @@ class StandardProfileTest extends WebTestBase {
* Tests that user data is exposed on user page.
*/
protected function doUserRdfaTests() {
- $this->drupalLogin($this->root_user);
+ $this->drupalLogin($this->rootUser);
// Feed the HTML into the parser.
$graph = $this->getRdfGraph($this->adminUser->getSystemPath());
diff --git a/core/modules/shortcut/src/Tests/ShortcutLinksTest.php b/core/modules/shortcut/src/Tests/ShortcutLinksTest.php
index d9cb0c7..dd637f1 100644
--- a/core/modules/shortcut/src/Tests/ShortcutLinksTest.php
+++ b/core/modules/shortcut/src/Tests/ShortcutLinksTest.php
@@ -104,7 +104,7 @@ class ShortcutLinksTest extends ShortcutTestBase {
$this->config('node.settings')->set('use_admin_theme', '1')->save();
$this->container->get('router.builder')->rebuild();
- $this->drupalLogin($this->root_user);
+ $this->drupalLogin($this->rootUser);
$this->drupalGet('admin/config/system/cron');
// Test the "Add to shortcuts" link.
@@ -165,7 +165,7 @@ class ShortcutLinksTest extends ShortcutTestBase {
* Tests that changing the route of a shortcut link works.
*/
public function testShortcutLinkChangeRoute() {
- $this->drupalLogin($this->root_user);
+ $this->drupalLogin($this->rootUser);
$this->drupalGet('admin/content');
$this->assertResponse(200);
// Disable the view.
@@ -242,7 +242,7 @@ class ShortcutLinksTest extends ShortcutTestBase {
->save();
// Add cron to the default shortcut set.
- $this->drupalLogin($this->root_user);
+ $this->drupalLogin($this->rootUser);
$this->drupalGet('admin/config/system/cron');
$this->clickLink('Add to Default shortcuts');
diff --git a/core/modules/simpletest/src/InstallerTestBase.php b/core/modules/simpletest/src/InstallerTestBase.php
index 09a71cb..d87718e 100644
--- a/core/modules/simpletest/src/InstallerTestBase.php
+++ b/core/modules/simpletest/src/InstallerTestBase.php
@@ -78,7 +78,7 @@ abstract class InstallerTestBase extends WebTestBase {
$this->isInstalled = FALSE;
// Define information about the user 1 account.
- $this->root_user = new UserSession(array(
+ $this->rootUser = new UserSession(array(
'uid' => 1,
'name' => 'admin',
'mail' => 'admin@example.com',
diff --git a/core/modules/simpletest/src/KernelTestBase.php b/core/modules/simpletest/src/KernelTestBase.php
index 6991181..1ce9eef 100644
--- a/core/modules/simpletest/src/KernelTestBase.php
+++ b/core/modules/simpletest/src/KernelTestBase.php
@@ -209,8 +209,8 @@ abstract class KernelTestBase extends TestBase {
// StreamWrapper APIs.
// @todo Move StreamWrapper management into DrupalKernel.
// @see https://drupal.org/node/2028109
- file_prepare_directory($this->public_files_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
- $this->settingsSet('file_public_path', $this->public_files_directory);
+ file_prepare_directory($this->publicFilesDirectory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
+ $this->settingsSet('file_public_path', $this->publicFilesDirectory);
$this->streamWrappers = array();
$this->registerStreamWrapper('public', 'Drupal\Core\StreamWrapper\PublicStream');
// The temporary stream wrapper is able to operate both with and without
diff --git a/core/modules/simpletest/src/TestBase.php b/core/modules/simpletest/src/TestBase.php
index 97b362e..7eaf71b 100644
--- a/core/modules/simpletest/src/TestBase.php
+++ b/core/modules/simpletest/src/TestBase.php
@@ -55,20 +55,6 @@ abstract class TestBase {
protected $databasePrefix = NULL;
/**
- * The site directory of the original parent site.
- *
- * @var string
- */
- protected $originalSite;
-
- /**
- * The original file directory, before it was changed for testing purposes.
- *
- * @var string
- */
- protected $originalFileDirectory = NULL;
-
- /**
* Time limit for the test.
*/
protected $timeLimit = 500;
@@ -133,6 +119,60 @@ abstract class TestBase {
protected $verboseDirectory;
/**
+ * URL to the verbose output file directory.
+ *
+ * @var string
+ */
+ protected $verboseDirectoryUrl;
+
+ /**
+ * The original configuration (variables), if available.
+ *
+ * @var string
+ * @todo Remove all remnants of $GLOBALS['conf'].
+ * @see https://drupal.org/node/2183323
+ */
+ protected $originalConf;
+
+ /**
+ * The original configuration (variables).
+ *
+ * @var string
+ */
+ protected $originalConfig;
+
+ /**
+ * The original configuration directories.
+ *
+ * An array of paths keyed by the CONFIG_*_DIRECTORY constants defined by
+ * core/includes/bootstrap.inc.
+ *
+ * @var array
+ */
+ protected $originalConfigDirectories;
+
+ /**
+ * The original container.
+ *
+ * @var \Symfony\Component\DependencyInjection\ContainerInterface
+ */
+ protected $originalContainer;
+
+ /**
+ * The original file directory, before it was changed for testing purposes.
+ *
+ * @var string
+ */
+ protected $originalFileDirectory = NULL;
+
+ /**
+ * The original language.
+ *
+ * @var \Drupal\Core\Language\LanguageInterface
+ */
+ protected $originalLanguage;
+
+ /**
* The original database prefix when running inside Simpletest.
*
* @var string
@@ -140,25 +180,55 @@ abstract class TestBase {
protected $originalPrefix;
/**
- * URL to the verbose output file directory.
+ * The original installation profile.
*
* @var string
*/
- protected $verboseDirectoryUrl;
+ protected $originalProfile;
+
+ /**
+ * The name of the session cookie.
+ *
+ * @var string
+ */
+ protected $originalSessionName;
/**
* The settings array.
+ *
+ * @var array
*/
protected $originalSettings;
/**
+ * The original array of shutdown function callbacks.
+ *
+ * @var array
+ */
+ protected $originalShutdownCallbacks;
+
+ /**
+ * The site directory of the original parent site.
+ *
+ * @var string
+ */
+ protected $originalSite;
+
+ /**
+ * The original user, before testing began.
+ *
+ * @var \Drupal\Core\Session\AccountProxyInterface
+ */
+ protected $originalUser;
+
+ /**
* The public file directory for the test environment.
*
* This is set in TestBase::prepareEnvironment().
*
* @var string
*/
- protected $public_files_directory;
+ protected $publicFilesDirectory;
/**
* The private file directory for the test environment.
@@ -167,7 +237,25 @@ abstract class TestBase {
*
* @var string
*/
- protected $private_files_directory;
+ protected $privateFilesDirectory;
+
+ /**
+ * The temporary file directory for the test environment.
+ *
+ * This is set in TestBase::prepareEnvironment().
+ *
+ * @var string
+ */
+ protected $tempFilesDirectory;
+
+ /**
+ * The translation file directory for the test environment.
+ *
+ * This is set in TestBase::prepareEnvironment().
+ *
+ * @var string
+ */
+ protected $translationFilesDirectory;
/**
* Whether to die in case any test assertion fails.
@@ -207,11 +295,6 @@ abstract class TestBase {
protected $randomGenerator;
/**
- * The name of the session cookie.
- */
- protected $originalSessionName;
-
- /**
* Set to TRUE to strict check all configuration saved.
*
* @see \Drupal\Core\Config\Testing\ConfigSchemaChecker
@@ -221,6 +304,21 @@ abstract class TestBase {
protected $strictConfigSchema = TRUE;
/**
+ * HTTP authentication method (specified as a CURLAUTH_* constant).
+ *
+ * @var int
+ * @see http://php.net/manual/en/function.curl-setopt.php
+ */
+ protected $httpAuthMethod = CURLAUTH_BASIC;
+
+ /**
+ * HTTP authentication credentials (<username>:<password>).
+ *
+ * @var string
+ */
+ protected $httpAuthCredentials = NULL;
+
+ /**
* Constructor for Test.
*
* @param $test_id
@@ -804,6 +902,7 @@ abstract class TestBase {
if (!isset($this->verbose)) {
$this->verbose = $simpletest_config->get('verbose');
}
+
if ($this->verbose) {
// Initialize verbose debugging.
$this->verbose = TRUE;
@@ -816,11 +915,11 @@ abstract class TestBase {
}
// HTTP auth settings (<username>:<password>) for the simpletest browser
// when sending requests to the test site.
- $this->httpauth_method = (int) $simpletest_config->get('httpauth.method');
+ $this->httpAuthMethod = (int) $simpletest_config->get('httpauth.method');
$username = $simpletest_config->get('httpauth.username');
$password = $simpletest_config->get('httpauth.password');
if (!empty($username) && !empty($password)) {
- $this->httpauth_credentials = $username . ':' . $password;
+ $this->httpAuthCredentials = $username . ':' . $password;
}
set_error_handler(array($this, 'errorHandler'));
@@ -1064,10 +1163,10 @@ abstract class TestBase {
file_prepare_directory($this->siteDirectory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
// Prepare filesystem directory paths.
- $this->public_files_directory = $this->siteDirectory . '/files';
- $this->private_files_directory = $this->siteDirectory . '/private';
- $this->temp_files_directory = $this->siteDirectory . '/temp';
- $this->translation_files_directory = $this->siteDirectory . '/translations';
+ $this->publicFilesDirectory = $this->siteDirectory . '/files';
+ $this->privateFilesDirectory = $this->siteDirectory . '/private';
+ $this->tempFilesDirectory = $this->siteDirectory . '/temp';
+ $this->translationFilesDirectory = $this->siteDirectory . '/translations';
$this->generatedTestFiles = FALSE;
diff --git a/core/modules/simpletest/src/Tests/BrokenSetUpTest.php b/core/modules/simpletest/src/Tests/BrokenSetUpTest.php
index 239a022..6621545 100644
--- a/core/modules/simpletest/src/Tests/BrokenSetUpTest.php
+++ b/core/modules/simpletest/src/Tests/BrokenSetUpTest.php
@@ -41,7 +41,7 @@ class BrokenSetUpTest extends WebTestBase {
if (!$this->isInChildSite()) {
parent::setUp();
- $this->sharedTriggerFile = $this->public_files_directory . '/trigger';
+ $this->sharedTriggerFile = $this->publicFilesDirectory . '/trigger';
// Create and log in user.
$admin_user = $this->drupalCreateUser(array('administer unit tests'));
diff --git a/core/modules/simpletest/src/Tests/InstallationProfileModuleTestsTest.php b/core/modules/simpletest/src/Tests/InstallationProfileModuleTestsTest.php
index 43b1c74..424469a 100644
--- a/core/modules/simpletest/src/Tests/InstallationProfileModuleTestsTest.php
+++ b/core/modules/simpletest/src/Tests/InstallationProfileModuleTestsTest.php
@@ -24,6 +24,13 @@ class InstallationProfileModuleTestsTest extends WebTestBase {
public static $modules = array('simpletest');
/**
+ * An administrative user with permission to adminsiter unit tests.
+ *
+ * @var \Drupal\user\UserInterface
+ */
+ protected $adminUser;
+
+ /**
* Use the Testing profile.
*
* The Testing profile contains drupal_system_listing_compatible_test.test,
@@ -40,8 +47,8 @@ class InstallationProfileModuleTestsTest extends WebTestBase {
protected function setUp() {
parent::setUp();
- $this->admin_user = $this->drupalCreateUser(array('administer unit tests'));
- $this->drupalLogin($this->admin_user);
+ $this->adminUser = $this->drupalCreateUser(array('administer unit tests'));
+ $this->drupalLogin($this->adminUser);
}
/**
diff --git a/core/modules/simpletest/src/Tests/OtherInstallationProfileTestsTest.php b/core/modules/simpletest/src/Tests/OtherInstallationProfileTestsTest.php
index 6e6e01b..9cfbfff 100644
--- a/core/modules/simpletest/src/Tests/OtherInstallationProfileTestsTest.php
+++ b/core/modules/simpletest/src/Tests/OtherInstallationProfileTestsTest.php
@@ -38,11 +38,18 @@ class OtherInstallationProfileTestsTest extends WebTestBase {
*/
protected $profile = 'minimal';
+ /**
+ * An administrative user with permission to administer unit tests.
+ *
+ * @var \Drupal\user\UserInterface
+ */
+ protected $adminUser;
+
protected function setUp() {
parent::setUp();
- $this->admin_user = $this->drupalCreateUser(array('administer unit tests'));
- $this->drupalLogin($this->admin_user);
+ $this->adminUser = $this->drupalCreateUser(array('administer unit tests'));
+ $this->drupalLogin($this->adminUser);
}
/**
diff --git a/core/modules/simpletest/src/Tests/SimpleTestTest.php b/core/modules/simpletest/src/Tests/SimpleTestTest.php
index 6942119..92a4529 100644
--- a/core/modules/simpletest/src/Tests/SimpleTestTest.php
+++ b/core/modules/simpletest/src/Tests/SimpleTestTest.php
@@ -38,7 +38,7 @@ class SimpleTestTest extends WebTestBase {
*
* Used to ensure they are incrementing.
*/
- protected $test_ids = array();
+ protected $testIds = array();
/**
* Translated fail message.
@@ -53,6 +53,20 @@ class SimpleTestTest extends WebTestBase {
*/
private $passMessage = '';
+ /**
+ * A valid and recognized permission.
+ *
+ * @var string
+ */
+ protected $validPermission;
+
+ /**
+ * An invalid or unrecognized permission.
+ *
+ * @var string
+ */
+ protected $invalidPermission;
+
protected function setUp() {
if (!$this->isInChildSite()) {
$php = <<<'EOD'
@@ -103,8 +117,8 @@ EOD;
function testWebTestRunner() {
$this->passMessage = t('SimpleTest pass.');
$this->failMessage = t('SimpleTest fail.');
- $this->valid_permission = 'access administration pages';
- $this->invalid_permission = 'invalid permission';
+ $this->validPermission = 'access administration pages';
+ $this->invalidPermission = 'invalid permission';
if ($this->isInChildSite()) {
// Only run following code if this test is running itself through a CURL
@@ -128,7 +142,7 @@ EOD;
// Regression test for #290316.
// Check that test_id is incrementing.
- $this->assertTrue($this->test_ids[0] != $this->test_ids[1], 'Test ID is incrementing.');
+ $this->assertTrue($this->testIds[0] != $this->testIds[1], 'Test ID is incrementing.');
}
}
@@ -162,10 +176,10 @@ EOD;
// This causes the second to fourth of the fifteen passes asserted in
// confirmStubResults().
- $user = $this->drupalCreateUser(array($this->valid_permission), 'SimpleTestTest');
+ $user = $this->drupalCreateUser(array($this->validPermission), 'SimpleTestTest');
// This causes the fifth of the five fails asserted in confirmStubResults().
- $this->drupalCreateUser(array($this->invalid_permission));
+ $this->drupalCreateUser(array($this->invalidPermission));
// Test logging in as a user.
// This causes the fifth to ninth of the fifteen passes asserted in
@@ -215,8 +229,8 @@ EOD;
$this->assertAssertion($this->passMessage, 'Other', 'Pass', 'SimpleTestTest.php', 'Drupal\simpletest\Tests\SimpleTestTest->stubTest()');
$this->assertAssertion($this->failMessage, 'Other', 'Fail', 'SimpleTestTest.php', 'Drupal\simpletest\Tests\SimpleTestTest->stubTest()');
- $this->assertAssertion(t('Created permissions: @perms', array('@perms' => $this->valid_permission)), 'Role', 'Pass', 'SimpleTestTest.php', 'Drupal\simpletest\Tests\SimpleTestTest->stubTest()');
- $this->assertAssertion(t('Invalid permission %permission.', array('%permission' => $this->invalid_permission)), 'Role', 'Fail', 'SimpleTestTest.php', 'Drupal\simpletest\Tests\SimpleTestTest->stubTest()');
+ $this->assertAssertion(t('Created permissions: @perms', array('@perms' => $this->validPermission)), 'Role', 'Pass', 'SimpleTestTest.php', 'Drupal\simpletest\Tests\SimpleTestTest->stubTest()');
+ $this->assertAssertion(t('Invalid permission %permission.', array('%permission' => $this->invalidPermission)), 'Role', 'Fail', 'SimpleTestTest.php', 'Drupal\simpletest\Tests\SimpleTestTest->stubTest()');
// Check that the user was logged in successfully.
$this->assertAssertion('User SimpleTestTest successfully logged in.', 'User login', 'Pass', 'SimpleTestTest.php', 'Drupal\simpletest\Tests\SimpleTestTest->stubTest()');
@@ -237,7 +251,7 @@ EOD;
$this->assertEqual('15 passes, 3 fails, 2 exceptions, 3 debug messages', $this->childTestResults['summary']);
- $this->test_ids[] = $test_id = $this->getTestIdFromResults();
+ $this->testIds[] = $test_id = $this->getTestIdFromResults();
$this->assertTrue($test_id, 'Found test ID in results.');
}
diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php
index af19ada..ec190a0 100644
--- a/core/modules/simpletest/src/WebTestBase.php
+++ b/core/modules/simpletest/src/WebTestBase.php
@@ -68,6 +68,13 @@ abstract class WebTestBase extends TestBase {
protected $headers;
/**
+ * The cookies of the page currently loaded in the internal browser.
+ *
+ * @var array
+ */
+ protected $cookies;
+
+ /**
* Indicates that headers should be dumped if verbose output is enabled.
*
* Headers are dumped to verbose by drupalGet(), drupalHead(), and
@@ -85,6 +92,14 @@ abstract class WebTestBase extends TestBase {
protected $loggedInUser = FALSE;
/**
+ * The "#1" admin user.
+ *
+ * @var \Drupal\Core\Session\AccountInterface
+ */
+ protected $rootUser;
+
+
+ /**
* The current cookie file used by cURL.
*
* We do not reuse the cookies in further runs, so we do not need a file
@@ -101,6 +116,13 @@ abstract class WebTestBase extends TestBase {
protected $additionalCurlOptions = array();
/**
+ * The original batch, before it was changed for testing purposes.
+ *
+ * @var array
+ */
+ protected $originalBatch;
+
+ /**
* The original user, before it was changed to a clean uid = 1 for testing.
*
* @var object
@@ -115,24 +137,14 @@ abstract class WebTestBase extends TestBase {
protected $originalShutdownCallbacks = array();
/**
- * HTTP authentication method.
- */
- protected $httpauth_method = CURLAUTH_BASIC;
-
- /**
- * HTTP authentication credentials (<username>:<password>).
- */
- protected $httpauth_credentials = NULL;
-
- /**
* The current session name, if available.
*/
- protected $session_name = NULL;
+ protected $sessionName = NULL;
/**
* The current session ID, if available.
*/
- protected $session_id = NULL;
+ protected $sessionId = NULL;
/**
* Whether the files were copied to the test files directory.
@@ -147,7 +159,7 @@ abstract class WebTestBase extends TestBase {
/**
* The number of redirects followed during the handling of a request.
*/
- protected $redirect_count;
+ protected $redirectCount;
/**
* The kernel used in this test.
@@ -678,8 +690,8 @@ abstract class WebTestBase extends TestBase {
$this->drupalPostForm('user/login', $edit, t('Log in'));
// @see WebTestBase::drupalUserIsLoggedIn()
- if (isset($this->session_id)) {
- $account->session_id = $this->session_id;
+ if (isset($this->sessionId)) {
+ $account->session_id = $this->sessionId;
}
$pass = $this->assert($this->drupalUserIsLoggedIn($account), format_string('User %name successfully logged in.', array('%name' => $account->getUsername())), 'User login');
if ($pass) {
@@ -732,7 +744,7 @@ abstract class WebTestBase extends TestBase {
* The name of the session cookie.
*/
public function getSessionName() {
- return $this->session_name;
+ return $this->sessionName;
}
/**
@@ -759,7 +771,7 @@ abstract class WebTestBase extends TestBase {
$this->originalBatch = batch_get();
// Define information about the user 1 account.
- $this->root_user = new UserSession(array(
+ $this->rootUser = new UserSession(array(
'uid' => 1,
'name' => 'admin',
'mail' => 'admin@example.com',
@@ -770,7 +782,7 @@ abstract class WebTestBase extends TestBase {
// proper session cookies were set on a response. Because the child site
// uses the same session name as the test runner, it is necessary to make
// that available to test-methods.
- $this->session_name = $this->originalSessionName;
+ $this->sessionName = $this->originalSessionName;
// Reset the static batch to remove Simpletest's batch operations.
$batch = &batch_get();
@@ -791,11 +803,11 @@ abstract class WebTestBase extends TestBase {
// @see system_requirements()
// @see TestBase::prepareEnvironment()
$settings['settings']['file_public_path'] = (object) array(
- 'value' => $this->public_files_directory,
+ 'value' => $this->publicFilesDirectory,
'required' => TRUE,
);
$settings['settings']['file_private_path'] = (object) array(
- 'value' => $this->private_files_directory,
+ 'value' => $this->privateFilesDirectory,
'required' => TRUE,
);
// Save the original site directory path, so that extensions in the
@@ -875,10 +887,10 @@ abstract class WebTestBase extends TestBase {
// While these could be preset/enforced in settings.php like the public
// files directory above, some tests expect them to be configurable in the
// UI. If declared in settings.php, they would no longer be configurable.
- file_prepare_directory($this->private_files_directory, FILE_CREATE_DIRECTORY);
- file_prepare_directory($this->temp_files_directory, FILE_CREATE_DIRECTORY);
+ file_prepare_directory($this->privateFilesDirectory, FILE_CREATE_DIRECTORY);
+ file_prepare_directory($this->tempFilesDirectory, FILE_CREATE_DIRECTORY);
$config->get('system.file')
- ->set('path.temporary', $this->temp_files_directory)
+ ->set('path.temporary', $this->tempFilesDirectory)
->save();
// Manually configure the test mail collector implementation to prevent
@@ -973,11 +985,11 @@ abstract class WebTestBase extends TestBase {
'site_name' => 'Drupal',
'site_mail' => 'simpletest@example.com',
'account' => array(
- 'name' => $this->root_user->name,
- 'mail' => $this->root_user->getEmail(),
+ 'name' => $this->rootUser->name,
+ 'mail' => $this->rootUser->getEmail(),
'pass' => array(
- 'pass1' => $this->root_user->pass_raw,
- 'pass2' => $this->root_user->pass_raw,
+ 'pass1' => $this->rootUser->pass_raw,
+ 'pass2' => $this->rootUser->pass_raw,
),
),
// \Drupal\Core\Render\Element\Checkboxes::valueCallback() requires
@@ -1209,7 +1221,7 @@ abstract class WebTestBase extends TestBase {
// Some versions/configurations of cURL break on a NULL cookie jar, so
// supply a real file.
if (empty($this->cookieFile)) {
- $this->cookieFile = $this->public_files_directory . '/cookie.jar';
+ $this->cookieFile = $this->publicFilesDirectory . '/cookie.jar';
}
$curl_options = array(
@@ -1224,9 +1236,9 @@ abstract class WebTestBase extends TestBase {
CURLOPT_HEADERFUNCTION => array(&$this, 'curlHeaderCallback'),
CURLOPT_USERAGENT => $this->databasePrefix,
);
- if (isset($this->httpauth_credentials)) {
- $curl_options[CURLOPT_HTTPAUTH] = $this->httpauth_method;
- $curl_options[CURLOPT_USERPWD] = $this->httpauth_credentials;
+ if (isset($this->httpAuthCredentials)) {
+ $curl_options[CURLOPT_HTTPAUTH] = $this->httpAuthMethod;
+ $curl_options[CURLOPT_USERPWD] = $this->httpAuthCredentials;
}
// curl_setopt_array() returns FALSE if any of the specified options
// cannot be set, and stops processing any further options.
@@ -1330,9 +1342,9 @@ abstract class WebTestBase extends TestBase {
if (!$redirect) {
// Reset headers, the session ID and the redirect counter.
- $this->session_id = NULL;
+ $this->sessionId = NULL;
$this->headers = array();
- $this->redirect_count = 0;
+ $this->redirectCount = 0;
}
$content = curl_exec($this->curlHandle);
@@ -1343,9 +1355,9 @@ abstract class WebTestBase extends TestBase {
// to prevent fragments being sent to the web server as part
// of the request.
// TODO: Remove this for Drupal 8, since fixed in curl 7.20.0.
- if (in_array($status, array(300, 301, 302, 303, 305, 307)) && $this->redirect_count < $this->maximumRedirects) {
+ if (in_array($status, array(300, 301, 302, 303, 305, 307)) && $this->redirectCount < $this->maximumRedirects) {
if ($this->drupalGetHeader('location')) {
- $this->redirect_count++;
+ $this->redirectCount++;
$curl_options = array();
$curl_options[CURLOPT_URL] = $this->drupalGetHeader('location');
$curl_options[CURLOPT_HTTPGET] = TRUE;
@@ -1404,12 +1416,12 @@ abstract class WebTestBase extends TestBase {
$parts = array_map('trim', explode(';', $matches[2]));
$value = array_shift($parts);
$this->cookies[$name] = array('value' => $value, 'secure' => in_array('secure', $parts));
- if ($name == $this->session_name) {
+ if ($name == $this->sessionName) {
if ($value != 'deleted') {
- $this->session_id = $value;
+ $this->sessionId = $value;
}
else {
- $this->session_id = NULL;
+ $this->sessionId = NULL;
}
}
}
diff --git a/core/modules/system/src/Tests/DrupalKernel/DrupalKernelTest.php b/core/modules/system/src/Tests/DrupalKernel/DrupalKernelTest.php
index 3c43f18..31b7ad1 100644
--- a/core/modules/system/src/Tests/DrupalKernel/DrupalKernelTest.php
+++ b/core/modules/system/src/Tests/DrupalKernel/DrupalKernelTest.php
@@ -30,7 +30,7 @@ class DrupalKernelTest extends KernelTestBase {
$this->settingsSet('php_storage', array('service_container' => array(
'bin' => 'service_container',
'class' => 'Drupal\Component\PhpStorage\MTimeProtectedFileStorage',
- 'directory' => DRUPAL_ROOT . '/' . $this->public_files_directory . '/php',
+ 'directory' => DRUPAL_ROOT . '/' . $this->publicFilesDirectory . '/php',
'secret' => Settings::getHashSalt(),
)));
}
diff --git a/core/modules/system/src/Tests/File/ConfigTest.php b/core/modules/system/src/Tests/File/ConfigTest.php
index 4d3cf6f..4eb7bf1 100644
--- a/core/modules/system/src/Tests/File/ConfigTest.php
+++ b/core/modules/system/src/Tests/File/ConfigTest.php
@@ -31,7 +31,7 @@ class ConfigTest extends WebTestBase {
// Set the file paths to non-default values.
// The respective directories are created automatically
// upon form submission.
- $file_path = $this->public_files_directory;
+ $file_path = $this->publicFilesDirectory;
$fields = array(
'file_temporary_path' => $file_path . '/file_config_page_test/temporary',
'file_default_scheme' => 'private',
diff --git a/core/modules/system/src/Tests/File/HtaccessUnitTest.php b/core/modules/system/src/Tests/File/HtaccessUnitTest.php
index ae66ff3..7d71a33 100644
--- a/core/modules/system/src/Tests/File/HtaccessUnitTest.php
+++ b/core/modules/system/src/Tests/File/HtaccessUnitTest.php
@@ -22,8 +22,8 @@ class HtaccessUnitTest extends KernelTestBase {
*/
function testHtaccessSave() {
// Prepare test directories.
- $public = $this->public_files_directory . '/test/public';
- $private = $this->public_files_directory . '/test/private';
+ $public = $this->publicFilesDirectory . '/test/public';
+ $private = $this->publicFilesDirectory . '/test/private';
$stream = 'public://test/stream';
// Verify that file_save_htaccess() returns FALSE if .htaccess cannot be
diff --git a/core/modules/system/src/Tests/Image/ToolkitGdTest.php b/core/modules/system/src/Tests/Image/ToolkitGdTest.php
index a65e683..f4face0 100644
--- a/core/modules/system/src/Tests/Image/ToolkitGdTest.php
+++ b/core/modules/system/src/Tests/Image/ToolkitGdTest.php
@@ -253,7 +253,7 @@ class ToolkitGdTest extends KernelTestBase {
}
// Prepare a directory for test file results.
- $directory = $this->public_files_directory .'/imagetest';
+ $directory = $this->publicFilesDirectory .'/imagetest';
file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
foreach ($files as $file) {
diff --git a/core/modules/system/src/Tests/Installer/DistributionProfileTest.php b/core/modules/system/src/Tests/Installer/DistributionProfileTest.php
index 05ed6f5..367510f 100644
--- a/core/modules/system/src/Tests/Installer/DistributionProfileTest.php
+++ b/core/modules/system/src/Tests/Installer/DistributionProfileTest.php
@@ -72,7 +72,7 @@ class DistributionProfileTest extends InstallerTestBase {
$this->assertUrl('user/1');
$this->assertResponse(200);
// Confirm that we are logged-in after installation.
- $this->assertText($this->root_user->getUsername());
+ $this->assertText($this->rootUser->getUsername());
}
}
diff --git a/core/modules/system/src/Tests/Installer/InstallerTest.php b/core/modules/system/src/Tests/Installer/InstallerTest.php
index 876e065..ee53a4e 100644
--- a/core/modules/system/src/Tests/Installer/InstallerTest.php
+++ b/core/modules/system/src/Tests/Installer/InstallerTest.php
@@ -23,7 +23,7 @@ class InstallerTest extends InstallerTestBase {
$this->assertUrl('user/1');
$this->assertResponse(200);
// Confirm that we are logged-in after installation.
- $this->assertText($this->root_user->getUsername());
+ $this->assertText($this->rootUser->getUsername());
// Verify that the confirmation message appears.
require_once \Drupal::root() . '/core/includes/install.inc';
diff --git a/core/modules/system/src/Tests/Installer/SingleVisibleProfileTest.php b/core/modules/system/src/Tests/Installer/SingleVisibleProfileTest.php
index a616703..35bcf74 100644
--- a/core/modules/system/src/Tests/Installer/SingleVisibleProfileTest.php
+++ b/core/modules/system/src/Tests/Installer/SingleVisibleProfileTest.php
@@ -62,7 +62,7 @@ class SingleVisibleProfileTest extends InstallerTestBase {
$this->assertUrl('user/1');
$this->assertResponse(200);
// Confirm that we are logged-in after installation.
- $this->assertText($this->root_user->getUsername());
+ $this->assertText($this->rootUser->getUsername());
// Confirm that the minimal profile was installed.
$this->assertEqual(drupal_get_profile(), 'minimal');
}
diff --git a/core/modules/system/src/Tests/Session/SessionTest.php b/core/modules/system/src/Tests/Session/SessionTest.php
index 7e9c16a..bbe23f6 100644
--- a/core/modules/system/src/Tests/Session/SessionTest.php
+++ b/core/modules/system/src/Tests/Session/SessionTest.php
@@ -285,10 +285,10 @@ class SessionTest extends WebTestBase {
*/
function assertSessionCookie($sent) {
if ($sent) {
- $this->assertNotNull($this->session_id, 'Session cookie was sent.');
+ $this->assertNotNull($this->sessionId, 'Session cookie was sent.');
}
else {
- $this->assertNull($this->session_id, 'Session cookie was not sent.');
+ $this->assertNull($this->sessionId, 'Session cookie was not sent.');
}
}
diff --git a/core/modules/system/src/Tests/System/DateFormatsLockedTest.php b/core/modules/system/src/Tests/System/DateFormatsLockedTest.php
index 7f9d6c0..13b7062 100644
--- a/core/modules/system/src/Tests/System/DateFormatsLockedTest.php
+++ b/core/modules/system/src/Tests/System/DateFormatsLockedTest.php
@@ -20,7 +20,7 @@ class DateFormatsLockedTest extends WebTestBase {
* Tests attempts at listing, editing, and deleting locked date formats.
*/
public function testDateLocking() {
- $this->drupalLogin($this->root_user);
+ $this->drupalLogin($this->rootUser);
// Locked date formats are not linked on the listing page, locked date
// formats are clearly marked as such; unlocked formats are not marked as
diff --git a/core/modules/system/src/Tests/Update/UpdateScriptTest.php b/core/modules/system/src/Tests/Update/UpdateScriptTest.php
index 360f5a6..5b09674 100644
--- a/core/modules/system/src/Tests/Update/UpdateScriptTest.php
+++ b/core/modules/system/src/Tests/Update/UpdateScriptTest.php
@@ -55,7 +55,7 @@ class UpdateScriptTest extends WebTestBase {
$this->assertResponse(200);
// Access the update page as user 1.
- $this->drupalLogin($this->root_user);
+ $this->drupalLogin($this->rootUser);
$this->drupalGet($this->update_url, array('external' => TRUE));
$this->assertResponse(200);
}