Commit b45af923 authored by webchick's avatar webchick

Issue #2382195 by tibbsa, subhojit777, tadityar, cilefen, Mile23: Clean-up...

Issue #2382195 by tibbsa, subhojit777, tadityar, cilefen, Mile23: Clean-up simpletest module test members - ensure property definition and use of camelCase naming convention
parent 41cb2391
...@@ -26,7 +26,7 @@ class BlockHtmlTest extends WebTestBase { ...@@ -26,7 +26,7 @@ class BlockHtmlTest extends WebTestBase {
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$this->drupalLogin($this->root_user); $this->drupalLogin($this->rootUser);
// Enable the test_html block, to test HTML ID and attributes. // Enable the test_html block, to test HTML ID and attributes.
\Drupal::state()->set('block_test.attributes', array('data-custom-attribute' => 'foo')); \Drupal::state()->set('block_test.attributes', array('data-custom-attribute' => 'foo'));
......
...@@ -46,7 +46,7 @@ protected function setUp() { ...@@ -46,7 +46,7 @@ protected function setUp() {
// roles are created then the role is lost after import. If the roles // 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 // created have the same name then the sync will fail because they will
// have different UUIDs. // have different UUIDs.
$this->drupalLogin($this->root_user); $this->drupalLogin($this->rootUser);
} }
/** /**
......
...@@ -27,7 +27,7 @@ class FieldUIRouteTest extends WebTestBase { ...@@ -27,7 +27,7 @@ class FieldUIRouteTest extends WebTestBase {
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$this->drupalLogin($this->root_user); $this->drupalLogin($this->rootUser);
} }
/** /**
......
...@@ -56,7 +56,7 @@ public function testConfigOverrideImport() { ...@@ -56,7 +56,7 @@ public function testConfigOverrideImport() {
$this->drupalGet('fr'); $this->drupalGet('fr');
$this->assertText('FR default site name'); $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->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'); $this->assertText('FR message: @site is currently under maintenance. We should be back shortly. Thank you for your patience');
} }
......
...@@ -34,7 +34,7 @@ public function setUp() { ...@@ -34,7 +34,7 @@ public function setUp() {
ConfigurableLanguage::createFromLangcode('fr')->save(); ConfigurableLanguage::createFromLangcode('fr')->save();
$this->config('system.site')->set('langcode', 'fr')->save(); $this->config('system.site')->set('langcode', 'fr')->save();
$this->drupalLogin($this->root_user); $this->drupalLogin($this->rootUser);
} }
/** /**
......
...@@ -53,7 +53,7 @@ protected function setUp() { ...@@ -53,7 +53,7 @@ protected function setUp() {
$this->noAccessUser2 = $this->drupalCreateUser(array('access content overview', 'access content')); $this->noAccessUser2 = $this->drupalCreateUser(array('access content overview', 'access content'));
$this->userMapping = [ $this->userMapping = [
1 => $this->root_user, 1 => $this->rootUser,
2 => $this->accessUser, 2 => $this->accessUser,
3 => $this->noAccessUser, 3 => $this->noAccessUser,
]; ];
......
...@@ -165,7 +165,7 @@ public function testAdminFrontPage() { ...@@ -165,7 +165,7 @@ public function testAdminFrontPage() {
// contextual links to the homepage view. This verifies there are no errors. // contextual links to the homepage view. This verifies there are no errors.
\Drupal::service('module_installer')->install(array('views_ui')); \Drupal::service('module_installer')->install(array('views_ui'));
// Login root user with sufficient permissions. // Login root user with sufficient permissions.
$this->drupalLogin($this->root_user); $this->drupalLogin($this->rootUser);
// Test frontpage view. // Test frontpage view.
$this->drupalGet('node'); $this->drupalGet('node');
$this->assertResponse(200); $this->assertResponse(200);
......
...@@ -290,7 +290,7 @@ protected function doPageRdfaTests() { ...@@ -290,7 +290,7 @@ protected function doPageRdfaTests() {
* Tests that user data is exposed on user page. * Tests that user data is exposed on user page.
*/ */
protected function doUserRdfaTests() { protected function doUserRdfaTests() {
$this->drupalLogin($this->root_user); $this->drupalLogin($this->rootUser);
// Feed the HTML into the parser. // Feed the HTML into the parser.
$graph = $this->getRdfGraph($this->adminUser->getSystemPath()); $graph = $this->getRdfGraph($this->adminUser->getSystemPath());
......
...@@ -104,7 +104,7 @@ public function testShortcutQuickLink() { ...@@ -104,7 +104,7 @@ public function testShortcutQuickLink() {
$this->config('node.settings')->set('use_admin_theme', '1')->save(); $this->config('node.settings')->set('use_admin_theme', '1')->save();
$this->container->get('router.builder')->rebuild(); $this->container->get('router.builder')->rebuild();
$this->drupalLogin($this->root_user); $this->drupalLogin($this->rootUser);
$this->drupalGet('admin/config/system/cron'); $this->drupalGet('admin/config/system/cron');
// Test the "Add to shortcuts" link. // Test the "Add to shortcuts" link.
...@@ -165,7 +165,7 @@ public function testShortcutLinkChangePath() { ...@@ -165,7 +165,7 @@ public function testShortcutLinkChangePath() {
* Tests that changing the route of a shortcut link works. * Tests that changing the route of a shortcut link works.
*/ */
public function testShortcutLinkChangeRoute() { public function testShortcutLinkChangeRoute() {
$this->drupalLogin($this->root_user); $this->drupalLogin($this->rootUser);
$this->drupalGet('admin/content'); $this->drupalGet('admin/content');
$this->assertResponse(200); $this->assertResponse(200);
// Disable the view. // Disable the view.
...@@ -242,7 +242,7 @@ public function testAccessShortcutsPermission() { ...@@ -242,7 +242,7 @@ public function testAccessShortcutsPermission() {
->save(); ->save();
// Add cron to the default shortcut set. // Add cron to the default shortcut set.
$this->drupalLogin($this->root_user); $this->drupalLogin($this->rootUser);
$this->drupalGet('admin/config/system/cron'); $this->drupalGet('admin/config/system/cron');
$this->clickLink('Add to Default shortcuts'); $this->clickLink('Add to Default shortcuts');
......
...@@ -78,7 +78,7 @@ protected function setUp() { ...@@ -78,7 +78,7 @@ protected function setUp() {
$this->isInstalled = FALSE; $this->isInstalled = FALSE;
// Define information about the user 1 account. // Define information about the user 1 account.
$this->root_user = new UserSession(array( $this->rootUser = new UserSession(array(
'uid' => 1, 'uid' => 1,
'name' => 'admin', 'name' => 'admin',
'mail' => 'admin@example.com', 'mail' => 'admin@example.com',
......
...@@ -209,8 +209,8 @@ protected function setUp() { ...@@ -209,8 +209,8 @@ protected function setUp() {
// StreamWrapper APIs. // StreamWrapper APIs.
// @todo Move StreamWrapper management into DrupalKernel. // @todo Move StreamWrapper management into DrupalKernel.
// @see https://drupal.org/node/2028109 // @see https://drupal.org/node/2028109
file_prepare_directory($this->public_files_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); file_prepare_directory($this->publicFilesDirectory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
$this->settingsSet('file_public_path', $this->public_files_directory); $this->settingsSet('file_public_path', $this->publicFilesDirectory);
$this->streamWrappers = array(); $this->streamWrappers = array();
$this->registerStreamWrapper('public', 'Drupal\Core\StreamWrapper\PublicStream'); $this->registerStreamWrapper('public', 'Drupal\Core\StreamWrapper\PublicStream');
// The temporary stream wrapper is able to operate both with and without // The temporary stream wrapper is able to operate both with and without
......
...@@ -54,20 +54,6 @@ abstract class TestBase { ...@@ -54,20 +54,6 @@ abstract class TestBase {
*/ */
protected $databasePrefix = NULL; 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. * Time limit for the test.
*/ */
...@@ -132,6 +118,60 @@ abstract class TestBase { ...@@ -132,6 +118,60 @@ abstract class TestBase {
*/ */
protected $verboseDirectory; 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. * The original database prefix when running inside Simpletest.
* *
...@@ -140,17 +180,47 @@ abstract class TestBase { ...@@ -140,17 +180,47 @@ abstract class TestBase {
protected $originalPrefix; protected $originalPrefix;
/** /**
* URL to the verbose output file directory. * The original installation profile.
* *
* @var string * @var string
*/ */
protected $verboseDirectoryUrl; protected $originalProfile;
/**
* The name of the session cookie.
*
* @var string
*/
protected $originalSessionName;
/** /**
* The settings array. * The settings array.
*
* @var array
*/ */
protected $originalSettings; 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. * The public file directory for the test environment.
* *
...@@ -158,7 +228,7 @@ abstract class TestBase { ...@@ -158,7 +228,7 @@ abstract class TestBase {
* *
* @var string * @var string
*/ */
protected $public_files_directory; protected $publicFilesDirectory;
/** /**
* The private file directory for the test environment. * The private file directory for the test environment.
...@@ -167,7 +237,25 @@ abstract class TestBase { ...@@ -167,7 +237,25 @@ abstract class TestBase {
* *
* @var string * @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. * Whether to die in case any test assertion fails.
...@@ -206,11 +294,6 @@ abstract class TestBase { ...@@ -206,11 +294,6 @@ abstract class TestBase {
*/ */
protected $randomGenerator; protected $randomGenerator;
/**
* The name of the session cookie.
*/
protected $originalSessionName;
/** /**
* Set to TRUE to strict check all configuration saved. * Set to TRUE to strict check all configuration saved.
* *
...@@ -220,6 +303,21 @@ abstract class TestBase { ...@@ -220,6 +303,21 @@ abstract class TestBase {
*/ */
protected $strictConfigSchema = TRUE; 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. * Constructor for Test.
* *
...@@ -804,6 +902,7 @@ public function run(array $methods = array()) { ...@@ -804,6 +902,7 @@ public function run(array $methods = array()) {
if (!isset($this->verbose)) { if (!isset($this->verbose)) {
$this->verbose = $simpletest_config->get('verbose'); $this->verbose = $simpletest_config->get('verbose');
} }
if ($this->verbose) { if ($this->verbose) {
// Initialize verbose debugging. // Initialize verbose debugging.
$this->verbose = TRUE; $this->verbose = TRUE;
...@@ -816,11 +915,11 @@ public function run(array $methods = array()) { ...@@ -816,11 +915,11 @@ public function run(array $methods = array()) {
} }
// HTTP auth settings (<username>:<password>) for the simpletest browser // HTTP auth settings (<username>:<password>) for the simpletest browser
// when sending requests to the test site. // 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'); $username = $simpletest_config->get('httpauth.username');
$password = $simpletest_config->get('httpauth.password'); $password = $simpletest_config->get('httpauth.password');
if (!empty($username) && !empty($password)) { if (!empty($username) && !empty($password)) {
$this->httpauth_credentials = $username . ':' . $password; $this->httpAuthCredentials = $username . ':' . $password;
} }
set_error_handler(array($this, 'errorHandler')); set_error_handler(array($this, 'errorHandler'));
...@@ -1064,10 +1163,10 @@ private function prepareEnvironment() { ...@@ -1064,10 +1163,10 @@ private function prepareEnvironment() {
file_prepare_directory($this->siteDirectory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); file_prepare_directory($this->siteDirectory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
// Prepare filesystem directory paths. // Prepare filesystem directory paths.
$this->public_files_directory = $this->siteDirectory . '/files'; $this->publicFilesDirectory = $this->siteDirectory . '/files';
$this->private_files_directory = $this->siteDirectory . '/private'; $this->privateFilesDirectory = $this->siteDirectory . '/private';
$this->temp_files_directory = $this->siteDirectory . '/temp'; $this->tempFilesDirectory = $this->siteDirectory . '/temp';
$this->translation_files_directory = $this->siteDirectory . '/translations'; $this->translationFilesDirectory = $this->siteDirectory . '/translations';
$this->generatedTestFiles = FALSE; $this->generatedTestFiles = FALSE;
......
...@@ -41,7 +41,7 @@ protected function setUp() { ...@@ -41,7 +41,7 @@ protected function setUp() {
if (!$this->isInChildSite()) { if (!$this->isInChildSite()) {
parent::setUp(); parent::setUp();
$this->sharedTriggerFile = $this->public_files_directory . '/trigger'; $this->sharedTriggerFile = $this->publicFilesDirectory . '/trigger';
// Create and log in user. // Create and log in user.
$admin_user = $this->drupalCreateUser(array('administer unit tests')); $admin_user = $this->drupalCreateUser(array('administer unit tests'));
......
...@@ -23,6 +23,13 @@ class InstallationProfileModuleTestsTest extends WebTestBase { ...@@ -23,6 +23,13 @@ class InstallationProfileModuleTestsTest extends WebTestBase {
*/ */
public static $modules = array('simpletest'); public static $modules = array('simpletest');
/**
* An administrative user with permission to adminsiter unit tests.
*
* @var \Drupal\user\UserInterface
*/
protected $adminUser;
/** /**
* Use the Testing profile. * Use the Testing profile.
* *
...@@ -40,8 +47,8 @@ class InstallationProfileModuleTestsTest extends WebTestBase { ...@@ -40,8 +47,8 @@ class InstallationProfileModuleTestsTest extends WebTestBase {
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$this->admin_user = $this->drupalCreateUser(array('administer unit tests')); $this->adminUser = $this->drupalCreateUser(array('administer unit tests'));
$this->drupalLogin($this->admin_user); $this->drupalLogin($this->adminUser);
} }
/** /**
......
...@@ -38,11 +38,18 @@ class OtherInstallationProfileTestsTest extends WebTestBase { ...@@ -38,11 +38,18 @@ class OtherInstallationProfileTestsTest extends WebTestBase {
*/ */
protected $profile = 'minimal'; protected $profile = 'minimal';
/**
* An administrative user with permission to administer unit tests.
*
* @var \Drupal\user\UserInterface
*/
protected $adminUser;
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$this->admin_user = $this->drupalCreateUser(array('administer unit tests')); $this->adminUser = $this->drupalCreateUser(array('administer unit tests'));
$this->drupalLogin($this->admin_user); $this->drupalLogin($this->adminUser);
} }
/** /**
......
...@@ -38,7 +38,7 @@ class SimpleTestTest extends WebTestBase { ...@@ -38,7 +38,7 @@ class SimpleTestTest extends WebTestBase {
* *
* Used to ensure they are incrementing. * Used to ensure they are incrementing.
*/ */
protected $test_ids = array(); protected $testIds = array();
/** /**
* Translated fail message. * Translated fail message.
...@@ -53,6 +53,20 @@ class SimpleTestTest extends WebTestBase { ...@@ -53,6 +53,20 @@ class SimpleTestTest extends WebTestBase {
*/ */
private $passMessage = ''; private $passMessage = '';
/**
* A valid and recognized permission.
*
* @var string
*/
protected $validPermission;
/**
* An invalid or unrecognized permission.
*
* @var string
*/
protected $invalidPermission;
protected function setUp() { protected function setUp() {
if (!$this->isInChildSite()) { if (!$this->isInChildSite()) {
$php = <<<'EOD' $php = <<<'EOD'
...@@ -103,8 +117,8 @@ class: Drupal\Core\Cache\MemoryBackendFactory ...@@ -103,8 +117,8 @@ class: Drupal\Core\Cache\MemoryBackendFactory
function testWebTestRunner() { function testWebTestRunner() {
$this->passMessage = t('SimpleTest pass.'); $this->passMessage = t('SimpleTest pass.');
$this->failMessage = t('SimpleTest fail.'); $this->failMessage = t('SimpleTest fail.');
$this->valid_permission = 'access administration pages'; $this->validPermission = 'access administration pages';
$this->invalid_permission = 'invalid permission'; $this->invalidPermission = 'invalid permission';
if ($this->isInChildSite()) { if ($this->isInChildSite()) {
// Only run following code if this test is running itself through a CURL // Only run following code if this test is running itself through a CURL
...@@ -128,7 +142,7 @@ function testWebTestRunner() { ...@@ -128,7 +142,7 @@ function testWebTestRunner() {
// Regression test for #290316. // Regression test for #290316.
// Check that test_id is incrementing. // 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 @@ function stubTest() { ...@@ -162,10 +176,10 @@ function stubTest() {
// This causes the second to fourth of the fifteen passes asserted in // This causes the second to fourth of the fifteen passes asserted in
// confirmStubResults(). // confirmStubResults().