diff --git a/core/modules/aggregator/aggregator.test b/core/modules/aggregator/aggregator.test index 8639389..1c9e536 100644 --- a/core/modules/aggregator/aggregator.test +++ b/core/modules/aggregator/aggregator.test @@ -8,16 +8,19 @@ use Drupal\simpletest\WebTestBase; class AggregatorTestCase extends WebTestBase { - function setUp() { - parent::setUp(array('node', 'block', 'aggregator', 'aggregator_test')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('node', 'block', 'aggregator', 'aggregator_test')); // Create an Article node type. if ($this->profile != 'standard') { $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); } - $web_user = $this->drupalCreateUser(array('administer news feeds', 'access news feeds', 'create article content')); - $this->drupalLogin($web_user); + $this->web_user = $this->drupalCreateUser(array('administer news feeds', 'access news feeds', 'create article content')); + } + + function setUp() { + $this->drupalLogin($this->web_user); } /** @@ -939,8 +942,8 @@ class FeedParserTestCase extends AggregatorTestCase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); // Do not remove old aggregator items during these tests, since our sample // feeds have hardcoded dates in them (which may be expired when this test // is run). diff --git a/core/modules/block/block.test b/core/modules/block/block.test index e6b2e42..bfed5ae 100644 --- a/core/modules/block/block.test +++ b/core/modules/block/block.test @@ -20,8 +20,8 @@ class BlockTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('block')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('block')); // Create Full HTML text format. $full_html_format = array( @@ -39,7 +39,6 @@ class BlockTestCase extends WebTestBase { filter_permission_name($full_html_format), 'access administration pages', )); - $this->drupalLogin($this->admin_user); // Define the existing regions $this->regions = array(); @@ -50,6 +49,10 @@ class BlockTestCase extends WebTestBase { $this->regions[] = 'footer'; } + function setUp() { + $this->drupalLogin($this->admin_user); + } + /** * Test creating custom block, moving it to a specific region and then deleting it. */ @@ -410,8 +413,8 @@ class NonDefaultBlockAdmin extends WebTestBase { ); } - function setUp() { - parent::setUp(array('block')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('block')); } /** @@ -438,8 +441,8 @@ class NewDefaultThemeBlocks extends WebTestBase { ); } - function setUp() { - parent::setUp(array('block')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('block')); } /** @@ -493,8 +496,8 @@ class BlockAdminThemeTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('block')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('block')); } /** @@ -533,8 +536,8 @@ class BlockCacheTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('block', 'block_test')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('block', 'block_test')); // Create an admin user, log in and enable test blocks. $this->admin_user = $this->drupalCreateUser(array('administer blocks', 'access administration pages')); @@ -717,8 +720,8 @@ class BlockHTMLIdTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('block', 'block_test')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('block', 'block_test')); // Create an admin user, log in and enable test blocks. $this->admin_user = $this->drupalCreateUser(array('administer blocks', 'access administration pages')); @@ -800,8 +803,8 @@ class BlockHiddenRegionTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('block', 'block_test', 'search')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('block', 'block_test', 'search')); // Enable Search block in default theme. db_merge('block') @@ -861,8 +864,8 @@ class BlockUserAccountSettingsTestCase extends WebTestBase { ); } - public function setUp() { - parent::setUp(array('block', 'field_ui')); + public function setUpBeforeClass() { + parent::setUpBeforeClass(array('block', 'field_ui')); $admin_user = $this->drupalCreateUser(array('administer users')); $this->drupalLogin($admin_user); } @@ -888,19 +891,14 @@ class BlockLanguageTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('language', 'block'); - } + function setUpBeforeClass() { + parent::setUpBeforeClass('language', 'block'); - /** - * Tests the visibility settings for the blocks based on language. - */ - public function testLanguageBlockVisibility() { // Create a new user, allow him to manage the blocks and the languages. - $admin_user = $this->drupalCreateUser(array( + $this->admin_user = $this->drupalCreateUser(array( 'administer languages', 'administer blocks', )); - $this->drupalLogin($admin_user); + $this->drupalLogin($this->admin_user); // Add predefined language. $edit = array( @@ -908,7 +906,16 @@ class BlockLanguageTestCase extends WebTestBase { ); $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); $this->assertText('French', t('Language added successfully.')); + } + function setUp() { + $this->drupalLogin($this->admin_user); + } + + /** + * Tests the visibility settings for the blocks based on language. + */ + public function testLanguageBlockVisibility() { // Check if the visibility setting is available. $this->drupalGet('admin/structure/block/add'); $this->assertField('langcodes[en]', t('Language visibility field is visible.')); @@ -952,22 +959,9 @@ class BlockLanguageTestCase extends WebTestBase { } /** - * Tests if the visibility settings are removed if the language is deleted. + * Tests if the visibility settings are removed if the block is deleted. */ - public function testLanguageBlockVisibilityLanguageDelete() { - // Create a new user, allow him to manage the blocks and the languages. - $admin_user = $this->drupalCreateUser(array( - 'administer languages', 'administer blocks', - )); - $this->drupalLogin($admin_user); - - // Add predefined language. - $edit = array( - 'predefined_langcode' => 'fr', - ); - $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); - $this->assertText('French', t('Language added successfully.')); - + public function testDeletedBlock() { // Create a new block. $info_name = $this->randomString(10); $body = ''; @@ -981,48 +975,36 @@ class BlockLanguageTestCase extends WebTestBase { 'body[value]' => $body, ); $this->drupalPost('admin/structure/block/add', $edit, t('Save block')); + $delta = db_query('SELECT bid FROM {block_custom} WHERE info = :info', array(':info' => $info_name))->fetchField(); // Set visibility setting for one language. $edit = array( 'langcodes[fr]' => TRUE, ); - $this->drupalPost('admin/structure/block/manage/block/1/configure', $edit, t('Save block')); + $this->drupalPost('admin/structure/block/manage/block/' . $delta . '/configure', $edit, t('Save block')); // Check that we have an entry in the database after saving the setting. $count = db_query('SELECT COUNT(langcode) FROM {block_language} WHERE module = :module AND delta = :delta', array( ':module' => 'block', - ':delta' => '1' + ':delta' => $delta, ))->fetchField(); $this->assertTrue($count == 1, t('The block language visibility has an entry in the database.')); - // Delete the language. - $this->drupalPost('admin/config/regional/language/delete/fr', array(), t('Delete')); + // Delete the custom block. + $this->drupalPost('admin/structure/block/manage/block/' . $delta . '/delete', array(), t('Delete')); - // Check that the setting related to this language has been deleted. + // Check that the setting related to this block has been deleted. $count = db_query('SELECT COUNT(langcode) FROM {block_language} WHERE module = :module AND delta = :delta', array( ':module' => 'block', - ':delta' => '1' + ':delta' => $delta, ))->fetchField(); $this->assertTrue($count == 0, t('The block language visibility do not have an entry in the database.')); } /** - * Tests if the visibility settings are removed if the block is deleted. + * Tests if the visibility settings are removed if the language is deleted. */ - public function testLanguageBlockVisibilityBlockDelete() { - // Create a new user, allow him to manage the blocks and the languages. - $admin_user = $this->drupalCreateUser(array( - 'administer languages', 'administer blocks', - )); - $this->drupalLogin($admin_user); - - // Add predefined language. - $edit = array( - 'predefined_langcode' => 'fr', - ); - $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); - $this->assertText('French', t('Language added successfully.')); - + public function testDeletedLanguage() { // Create a new block. $info_name = $this->randomString(10); $body = ''; @@ -1036,27 +1018,36 @@ class BlockLanguageTestCase extends WebTestBase { 'body[value]' => $body, ); $this->drupalPost('admin/structure/block/add', $edit, t('Save block')); + $delta = db_query('SELECT bid FROM {block_custom} WHERE info = :info', array(':info' => $info_name))->fetchField(); // Set visibility setting for one language. $edit = array( 'langcodes[fr]' => TRUE, ); - $this->drupalPost('admin/structure/block/manage/block/1/configure', $edit, t('Save block')); + $this->drupalPost('admin/structure/block/manage/block/' . $delta . '/configure', $edit, t('Save block')); // Check that we have an entry in the database after saving the setting. $count = db_query('SELECT COUNT(langcode) FROM {block_language} WHERE module = :module AND delta = :delta', array( ':module' => 'block', - ':delta' => '1' + ':delta' => $delta, ))->fetchField(); $this->assertTrue($count == 1, t('The block language visibility has an entry in the database.')); - // Delete the custom block. - $this->drupalPost('admin/structure/block/manage/block/1/delete', array(), t('Delete')); + // Ensure that French is not the default language. + variable_set('language_default', (object) array( + 'langcode' => 'en', + 'name' => 'English', + 'direction' => 0, + 'weight' => 0, + )); - // Check that the setting related to this block has been deleted. + // Delete the language. + $this->drupalPost('admin/config/regional/language/delete/fr', array(), t('Delete')); + + // Check that the setting related to this language has been deleted. $count = db_query('SELECT COUNT(langcode) FROM {block_language} WHERE module = :module AND delta = :delta', array( ':module' => 'block', - ':delta' => '1' + ':delta' => $delta, ))->fetchField(); $this->assertTrue($count == 0, t('The block language visibility do not have an entry in the database.')); } @@ -1074,8 +1065,8 @@ class BlockInvalidRegionTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('block', 'block_test')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('block', 'block_test')); // Create an admin user. $admin_user = $this->drupalCreateUser(array('administer site configuration', 'access administration pages')); $this->drupalLogin($admin_user); diff --git a/core/modules/book/book.test b/core/modules/book/book.test index 00995cb..3ae422d 100644 --- a/core/modules/book/book.test +++ b/core/modules/book/book.test @@ -26,8 +26,8 @@ class BookTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('book', 'block', 'node_access_test')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('book', 'block', 'node_access_test')); // node_access_test requires a node_access_rebuild(). node_access_rebuild(); diff --git a/core/modules/color/color.test b/core/modules/color/color.test index 8835e5b..6470878 100644 --- a/core/modules/color/color.test +++ b/core/modules/color/color.test @@ -23,8 +23,8 @@ class ColorTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('color'); + function setUpBeforeClass() { + parent::setUpBeforeClass('color'); // Create users. $this->big_user = $this->drupalCreateUser(array('administer themes')); diff --git a/core/modules/comment/comment.test b/core/modules/comment/comment.test index 1ede063..0bc6371 100644 --- a/core/modules/comment/comment.test +++ b/core/modules/comment/comment.test @@ -434,7 +434,7 @@ class CommentInterfaceTest extends CommentTestBase { theme_enable(array('stark')); variable_set('theme_default', 'stark'); - // Remove additional user permissions from $this->web_user added by setUp(), + // Remove additional user permissions from $this->web_user added by setUpBeforeClass(), // since this test is limited to anonymous and authenticated roles only. user_role_delete(key($this->web_user->roles)); @@ -839,8 +839,8 @@ class CommentAnonymous extends CommentTestBase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); variable_set('user_register', USER_REGISTER_VISITORS); } @@ -1262,8 +1262,8 @@ class CommentNodeAccessTest extends CommentTestBase { ); } - function setUp() { - WebTestBase::setUp('comment', 'search', 'node_access_test'); + function setUpBeforeClass() { + WebTestBase::setUpBeforeClass('comment', 'search', 'node_access_test'); node_access_rebuild(); // Create users and test node. diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php index 093f91b..f31c97b 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php @@ -17,8 +17,8 @@ class CommentTestBase extends WebTestBase { protected $web_user; protected $node; - function setUp() { - parent::setUp('comment', 'search'); + function setUpBeforeClass() { + parent::setUpBeforeClass('comment', 'search'); // Create users and test node. $this->admin_user = $this->drupalCreateUser(array('administer content types', 'administer comments', 'administer blocks')); $this->web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'create article content', 'edit own comments')); diff --git a/core/modules/config/config.test b/core/modules/config/config.test index 257ab0f..adb0e25 100644 --- a/core/modules/config/config.test +++ b/core/modules/config/config.test @@ -62,8 +62,8 @@ class ConfigFileContentTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); $this->fileExtension = FileStorage::getFileExtension(); } @@ -329,8 +329,8 @@ class ConfUpdate7to8TestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('config_upgrade'); + function setUpBeforeClass() { + parent::setUpBeforeClass('config_upgrade'); require_once DRUPAL_ROOT . '/core/includes/update.inc'; } diff --git a/core/modules/contact/contact.test b/core/modules/contact/contact.test index 3c7f61a..3d0595f 100644 --- a/core/modules/contact/contact.test +++ b/core/modules/contact/contact.test @@ -18,8 +18,12 @@ class ContactSitewideTestCase extends WebTestBase { ); } + function setUpBeforeClass() { + parent::setUpBeforeClass('contact'); + } + function setUp() { - parent::setUp('contact'); + db_truncate('contact')->execute(); } /** @@ -173,14 +177,14 @@ class ContactSitewideTestCase extends WebTestBase { // Set up three categories, 2 with an auto-reply and one without. $foo_autoreply = $this->randomName(40); $bar_autoreply = $this->randomName(40); - $this->addCategory('foo', 'foo@example.com', $foo_autoreply, FALSE); - $this->addCategory('bar', 'bar@example.com', $bar_autoreply, FALSE); - $this->addCategory('no_autoreply', 'bar@example.com', '', FALSE); + $foo = $this->addCategory('foo', 'foo@example.com', $foo_autoreply, FALSE); + $bar = $this->addCategory('bar', 'bar@example.com', $bar_autoreply, FALSE); + $no_autoreply = $this->addCategory('no_autoreply', 'bar@example.com', '', FALSE); // Test the auto-reply for category 'foo'. $email = $this->randomName(32) . '@example.com'; $subject = $this->randomName(64); - $this->submitContact($this->randomName(16), $email, $subject, 2, $this->randomString(128)); + $this->submitContact($this->randomName(16), $email, $subject, $foo, $this->randomString(128)); // We are testing the auto-reply, so there should be one e-mail going to the sender. $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email, 'from' => 'foo@example.com')); @@ -189,7 +193,7 @@ class ContactSitewideTestCase extends WebTestBase { // Test the auto-reply for category 'bar'. $email = $this->randomName(32) . '@example.com'; - $this->submitContact($this->randomName(16), $email, $this->randomString(64), 3, $this->randomString(128)); + $this->submitContact($this->randomName(16), $email, $this->randomString(64), $bar, $this->randomString(128)); // Auto-reply for category 'bar' should result in one auto-reply e-mail to the sender. $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email, 'from' => 'bar@example.com')); @@ -198,7 +202,7 @@ class ContactSitewideTestCase extends WebTestBase { // Verify that no auto-reply is sent when the auto-reply field is left blank. $email = $this->randomName(32) . '@example.com'; - $this->submitContact($this->randomName(16), $email, $this->randomString(64), 4, $this->randomString(128)); + $this->submitContact($this->randomName(16), $email, $this->randomString(64), $no_autoreply, $this->randomString(128)); $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email, 'from' => 'no_autoreply@example.com')); $this->assertEqual(count($captured_emails), 0, t('No auto-reply e-mail was sent to the sender for category "no-autoreply".'), t('Contact')); } @@ -223,6 +227,7 @@ class ContactSitewideTestCase extends WebTestBase { $edit['reply'] = $reply; $edit['selected'] = ($selected ? TRUE : FALSE); $this->drupalPost('admin/structure/contact/add', $edit, t('Save')); + return db_query('SELECT cid FROM {contact} WHERE category = :category', array(':category' => $category))->fetchField(); } /** @@ -313,18 +318,21 @@ class ContactPersonalTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('contact'); + function setUpBeforeClass() { + parent::setUpBeforeClass('contact'); // Create an admin user. $this->admin_user = $this->drupalCreateUser(array('administer contact forms', 'administer users')); // Create some normal users with their contact forms enabled by default. - variable_set('contact_default_status', TRUE); $this->web_user = $this->drupalCreateUser(array('access user contact forms')); $this->contact_user = $this->drupalCreateUser(); } + function setUp() { + variable_set('contact_default_status', TRUE); + } + /** * Tests access to the personal contact form. */ @@ -362,30 +370,30 @@ class ContactPersonalTestCase extends WebTestBase { // Re-create our contacted user with personal contact forms disabled by // default. - $this->contact_user = $this->drupalCreateUser(); + $contact_user = $this->drupalCreateUser(); // Test denied access to a user with contact form disabled. $this->drupalLogin($this->web_user); - $this->drupalGet('user/' . $this->contact_user->uid . '/contact'); + $this->drupalGet('user/' . $contact_user->uid . '/contact'); $this->assertResponse(403); // Test allowed access for admin user to a user with contact form disabled. $this->drupalLogin($this->admin_user); - $this->drupalGet('user/' . $this->contact_user->uid . '/contact'); + $this->drupalGet('user/' . $contact_user->uid . '/contact'); $this->assertResponse(200); // Re-create our contacted user as a blocked user. - $this->contact_user = $this->drupalCreateUser(); - $this->contact_user->status = 0; - $this->contact_user->save(); + $contact_user = $this->drupalCreateUser(); + $contact_user->status = 0; + $contact_user->save(); // Test that blocked users can still be contacted by admin. - $this->drupalGet('user/' . $this->contact_user->uid . '/contact'); + $this->drupalGet('user/' . $contact_user->uid . '/contact'); $this->assertResponse(200); // Test that blocked users cannot be contacted by non-admins. $this->drupalLogin($this->web_user); - $this->drupalGet('user/' . $this->contact_user->uid . '/contact'); + $this->drupalGet('user/' . $contact_user->uid . '/contact'); $this->assertResponse(403); } @@ -416,6 +424,7 @@ class ContactPersonalTestCase extends WebTestBase { // Test that the admin user can still access the contact form even though // the flood limit was reached. $this->drupalLogin($this->admin_user); + $this->drupalGet('user/' . $this->contact_user->uid. '/contact'); $this->assertNoText('Try again later.', 'Admin user not denied access to flooded contact form.'); } diff --git a/core/modules/contextual/contextual.test b/core/modules/contextual/contextual.test index 8749f3a..3fdb919 100644 --- a/core/modules/contextual/contextual.test +++ b/core/modules/contextual/contextual.test @@ -19,8 +19,8 @@ class ContextualDynamicContextTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('contextual', 'node')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('contextual', 'node')); $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); $web_user = $this->drupalCreateUser(array('access content', 'access contextual links', 'edit any article content')); diff --git a/core/modules/dashboard/dashboard.test b/core/modules/dashboard/dashboard.test index 2808dc4..e26d497 100644 --- a/core/modules/dashboard/dashboard.test +++ b/core/modules/dashboard/dashboard.test @@ -20,12 +20,15 @@ class DashboardBlocksTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('block', 'dashboard')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('block', 'dashboard')); // Create and log in an administrative user having access to the dashboard. - $admin_user = $this->drupalCreateUser(array('access dashboard', 'administer blocks', 'access administration pages', 'administer modules')); - $this->drupalLogin($admin_user); + $this->admin_user = $this->drupalCreateUser(array('access dashboard', 'administer blocks', 'access administration pages', 'administer modules')); + } + + function setUp() { + $this->drupalLogin($this->admin_user); } /** @@ -120,8 +123,8 @@ class DashboardBlockAvailabilityTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); // Create and log in an administrative user having access to the dashboard. $admin_user = $this->drupalCreateUser(array('access dashboard', 'administer blocks', 'access administration pages', 'administer modules')); diff --git a/core/modules/dblog/dblog.test b/core/modules/dblog/dblog.test index 92763c1..64de830 100644 --- a/core/modules/dblog/dblog.test +++ b/core/modules/dblog/dblog.test @@ -25,8 +25,8 @@ class DBLogTestCase extends WebTestBase { /** * Enable modules and create users with specific permissions. */ - function setUp() { - parent::setUp('dblog', 'poll'); + function setUpBeforeClass() { + parent::setUpBeforeClass('dblog', 'poll'); // Create users. $this->big_user = $this->drupalCreateUser(array('administer site configuration', 'access administration pages', 'access site reports', 'administer users')); $this->any_user = $this->drupalCreateUser(array()); diff --git a/core/modules/entity/tests/entity.test b/core/modules/entity/tests/entity.test index 1047279..272432c 100644 --- a/core/modules/entity/tests/entity.test +++ b/core/modules/entity/tests/entity.test @@ -20,8 +20,8 @@ class EntityAPITestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('entity', 'entity_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('entity', 'entity_test'); } /** @@ -104,8 +104,8 @@ class EntityTranslationTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('entity_test', 'language', 'locale'); + function setUpBeforeClass() { + parent::setUpBeforeClass('entity_test', 'language', 'locale'); // Enable translations for the test entity type. variable_set('entity_test_translation', TRUE); diff --git a/core/modules/entity/tests/entity_crud_hook_test.test b/core/modules/entity/tests/entity_crud_hook_test.test index dd4aa70..499be8a 100644 --- a/core/modules/entity/tests/entity_crud_hook_test.test +++ b/core/modules/entity/tests/entity_crud_hook_test.test @@ -31,8 +31,8 @@ class EntityCrudHookTestCase extends WebTestBase { ); } - public function setUp() { - parent::setUp('entity_crud_hook_test', 'taxonomy', 'comment'); + public function setUpBeforeClass() { + parent::setUpBeforeClass('entity_crud_hook_test', 'taxonomy', 'comment'); } /** diff --git a/core/modules/entity/tests/entity_query.test b/core/modules/entity/tests/entity_query.test index 52018e4..393043b 100644 --- a/core/modules/entity/tests/entity_query.test +++ b/core/modules/entity/tests/entity_query.test @@ -23,8 +23,8 @@ class EntityFieldQueryTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('field_test')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('field_test')); field_test_create_bundle('bundle1'); field_test_create_bundle('bundle2'); diff --git a/core/modules/field/modules/field_sql_storage/field_sql_storage.test b/core/modules/field/modules/field_sql_storage/field_sql_storage.test index 2a90434..e92fa70 100644 --- a/core/modules/field/modules/field_sql_storage/field_sql_storage.test +++ b/core/modules/field/modules/field_sql_storage/field_sql_storage.test @@ -24,8 +24,8 @@ class FieldSqlStorageTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('field_sql_storage', 'field', 'field_test', 'text', 'number'); + function setUpBeforeClass() { + parent::setUpBeforeClass('field_sql_storage', 'field', 'field_test', 'text', 'number'); $this->field_name = strtolower($this->randomName()); $this->field = array('field_name' => $this->field_name, 'type' => 'test_field', 'cardinality' => 4); $this->field = field_create_field($this->field); diff --git a/core/modules/field/modules/list/tests/list.test b/core/modules/field/modules/list/tests/list.test index 8999b06..f670c43 100644 --- a/core/modules/field/modules/list/tests/list.test +++ b/core/modules/field/modules/list/tests/list.test @@ -20,8 +20,8 @@ class ListFieldTestCase extends FieldTestCase { ); } - function setUp() { - parent::setUp(array('list', 'field_test')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('list', 'field_test')); $this->field_name = 'test_list'; $this->field = array( @@ -120,8 +120,8 @@ class ListFieldTestCase extends FieldTestCase { * Sets up a List field for testing allowed values functions. */ class ListDynamicValuesTestCase extends FieldTestCase { - function setUp() { - parent::setUp(array('list', 'field_test', 'list_test')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('list', 'field_test', 'list_test')); $this->field_name = 'test_list'; $this->field = array( @@ -211,8 +211,8 @@ class ListFieldUITestCase extends FieldTestCase { ); } - function setUp() { - parent::setUp(array('list', 'field_test', 'taxonomy', 'field_ui')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('list', 'field_test', 'taxonomy', 'field_ui')); // Create test user. $admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer taxonomy')); diff --git a/core/modules/field/modules/number/number.test b/core/modules/field/modules/number/number.test index ddf9f1f..b73f9a1 100644 --- a/core/modules/field/modules/number/number.test +++ b/core/modules/field/modules/number/number.test @@ -23,8 +23,8 @@ class NumberFieldTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('node', 'field_test', 'number', 'field_ui')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('node', 'field_test', 'number', 'field_ui')); $this->web_user = $this->drupalCreateUser(array('access field_test content', 'administer field_test content', 'administer content types')); $this->drupalLogin($this->web_user); } diff --git a/core/modules/field/modules/options/options.test b/core/modules/field/modules/options/options.test index be446cd..bfc608c 100644 --- a/core/modules/field/modules/options/options.test +++ b/core/modules/field/modules/options/options.test @@ -14,8 +14,8 @@ class OptionsWidgetsTestCase extends FieldTestCase { ); } - function setUp() { - parent::setUp(array('list', 'field_test', 'list_test', 'taxonomy', 'field_ui')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('list', 'field_test', 'list_test', 'taxonomy', 'field_ui')); // Field with cardinality 1. $this->card_1 = array( diff --git a/core/modules/field/modules/text/text.test b/core/modules/field/modules/text/text.test index a41e8cd..1d4b32f 100644 --- a/core/modules/field/modules/text/text.test +++ b/core/modules/field/modules/text/text.test @@ -21,8 +21,8 @@ class TextFieldTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('field_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('field_test'); $this->admin_user = $this->drupalCreateUser(array('administer filters')); $this->web_user = $this->drupalCreateUser(array('access field_test content', 'administer field_test content')); @@ -251,8 +251,8 @@ class TextSummaryTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); $this->article_creator = $this->drupalCreateUser(array('create article content', 'edit own article content')); } @@ -421,8 +421,8 @@ class TextTranslationTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('locale', 'translation'); + function setUpBeforeClass() { + parent::setUpBeforeClass('locale', 'translation'); $full_html_format = filter_format_load('full_html'); $this->format = $full_html_format->format; diff --git a/core/modules/field/tests/field.test b/core/modules/field/tests/field.test index ca4de1b..c704870 100644 --- a/core/modules/field/tests/field.test +++ b/core/modules/field/tests/field.test @@ -19,16 +19,16 @@ class FieldTestCase extends WebTestBase { /** * Set the default field storage backend for fields created during tests. */ - function setUp() { + function setUpBeforeClass() { // Since this is a base class for many test cases, support the same - // flexibility that Drupal\simpletest\WebTestBase::setUp() has for the + // flexibility that Drupal\simpletest\WebTestBase::setUpBeforeClass() has for the // modules to be passed in as either an array or a variable number of string // arguments. $modules = func_get_args(); if (isset($modules[0]) && is_array($modules[0])) { $modules = $modules[0]; } - parent::setUp($modules); + parent::setUpBeforeClass($modules); // Set default storage backend. variable_set('field_storage_default', $this->default_storage); } @@ -78,9 +78,9 @@ class FieldTestCase extends WebTestBase { } class FieldAttachTestCase extends FieldTestCase { - function setUp() { + function setUpBeforeClass() { // Since this is a base class for many test cases, support the same - // flexibility that Drupal\simpletest\WebTestBase::setUp() has for the + // flexibility that Drupal\simpletest\WebTestBase::setUpBeforeClass() has for the // modules to be passed in as either an array or a variable number of string // arguments. $modules = func_get_args(); @@ -90,7 +90,7 @@ class FieldAttachTestCase extends FieldTestCase { if (!in_array('field_test', $modules)) { $modules[] = 'field_test'; } - parent::setUp($modules); + parent::setUpBeforeClass($modules); $this->field_name = drupal_strtolower($this->randomName() . '_field_name'); $this->field = array('field_name' => $this->field_name, 'type' => 'test_field', 'cardinality' => 4); @@ -1035,8 +1035,8 @@ class FieldInfoTestCase extends FieldTestCase { ); } - function setUp() { - parent::setUp('field_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('field_test'); } /** @@ -1292,8 +1292,8 @@ class FieldFormTestCase extends FieldTestCase { ); } - function setUp() { - parent::setUp(array('node', 'field_test', 'list')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('node', 'field_test', 'list')); $web_user = $this->drupalCreateUser(array('access field_test content', 'administer field_test content')); $this->drupalLogin($web_user); @@ -1818,8 +1818,8 @@ class FieldDisplayAPITestCase extends FieldTestCase { ); } - function setUp() { - parent::setUp('field_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('field_test'); // Create a field and instance. $this->field_name = 'test_field'; @@ -2012,9 +2012,9 @@ class FieldCrudTestCase extends FieldTestCase { ); } - function setUp() { + function setUpBeforeClass() { // field_update_field() tests use number.module - parent::setUp('field_test', 'number'); + parent::setUpBeforeClass('field_test', 'number'); } // TODO : test creation with @@ -2475,8 +2475,8 @@ class FieldInstanceCrudTestCase extends FieldTestCase { ); } - function setUp() { - parent::setUp('field_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('field_test'); $this->field = array( 'field_name' => drupal_strtolower($this->randomName()), @@ -2703,8 +2703,8 @@ class FieldTranslationsTestCase extends FieldTestCase { ); } - function setUp() { - parent::setUp('locale', 'field_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('locale', 'field_test'); $this->field_name = drupal_strtolower($this->randomName() . '_field_name'); @@ -3118,8 +3118,8 @@ class FieldBulkDeleteTestCase extends FieldTestCase { } } - function setUp() { - parent::setUp('field_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('field_test'); $this->fields = array(); $this->instances = array(); @@ -3177,7 +3177,7 @@ class FieldBulkDeleteTestCase extends FieldTestCase { * * This tests how EntityFieldQuery interacts with * field_delete_instance() and could be moved to FieldCrudTestCase, - * but depends on this class's setUp(). + * but depends on this class's setUpBeforeClass(). */ function testDeleteFieldInstance() { $bundle = reset($this->bundles); @@ -3379,8 +3379,8 @@ class EntityPropertiesTestCase extends FieldTestCase { ); } - function setUp() { - parent::setUp('field_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('field_test'); } /** diff --git a/core/modules/field_ui/field_ui.test b/core/modules/field_ui/field_ui.test index c33552c..168a35c 100644 --- a/core/modules/field_ui/field_ui.test +++ b/core/modules/field_ui/field_ui.test @@ -13,9 +13,9 @@ use Drupal\simpletest\WebTestBase; */ class FieldUITestCase extends WebTestBase { - function setUp() { + function setUpBeforeClass() { // Since this is a base class for many test cases, support the same - // flexibility that Drupal\simpletest\WebTestBase::setUp() has for the + // flexibility that Drupal\simpletest\WebTestBase::setUpBeforeClass() has for the // modules to be passed in as either an array or a variable number of string // arguments. $modules = func_get_args(); @@ -26,7 +26,7 @@ class FieldUITestCase extends WebTestBase { $modules[] = 'field_ui'; $modules[] = 'field_test'; $modules[] = 'taxonomy'; - parent::setUp($modules); + parent::setUpBeforeClass($modules); // Create test user. $admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer taxonomy')); @@ -147,8 +147,8 @@ class FieldUIManageFieldsTestCase extends FieldUITestCase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); // Create random field name. $this->field_label = $this->randomName(8); @@ -488,8 +488,8 @@ class FieldUIManageDisplayTestCase extends FieldUITestCase { ); } - function setUp() { - parent::setUp(array('search')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('search')); } /** @@ -707,8 +707,8 @@ class FieldUIAlterTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('field_ui', 'field_test', 'text', 'list')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('field_ui', 'field_test', 'text', 'list')); // Create Article node type. $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); diff --git a/core/modules/file/tests/file.test b/core/modules/file/tests/file.test index a826c14..0a4ec36 100644 --- a/core/modules/file/tests/file.test +++ b/core/modules/file/tests/file.test @@ -15,9 +15,9 @@ class FileFieldTestCase extends WebTestBase { protected $admin_user; - function setUp() { + function setUpBeforeClass() { // Since this is a base class for many test cases, support the same - // flexibility that Drupal\simpletest\WebTestBase::setUp() has for the + // flexibility that Drupal\simpletest\WebTestBase::setUpBeforeClass() has for the // modules to be passed in as either an array or a variable number of string // arguments. $modules = func_get_args(); @@ -26,8 +26,11 @@ class FileFieldTestCase extends WebTestBase { } $modules[] = 'file'; $modules[] = 'file_module_test'; - parent::setUp($modules); + parent::setUpBeforeClass($modules); $this->admin_user = $this->drupalCreateUser(array('access content', 'access administration pages', 'administer site configuration', 'administer users', 'administer permissions', 'administer content types', 'administer nodes', 'bypass node access')); + } + + function setUp() { $this->drupalLogin($this->admin_user); } @@ -73,9 +76,10 @@ class FileFieldTestCase extends WebTestBase { 'cardinality' => !empty($field_settings['cardinality']) ? $field_settings['cardinality'] : 1, ); $field['settings'] = array_merge($field['settings'], $field_settings); - field_create_field($field); + $field = field_create_field($field); $this->attachFileField($name, 'node', $type_name, $instance_settings, $widget_settings); + return $field; } /** @@ -331,20 +335,19 @@ class FileFieldWidgetTestCase extends FileFieldTestCase { ); } + function setUpBeforeClass() { + parent::setUpBeforeClass(); + + $this->type_name = 'page'; + $this->field_name = strtolower($this->randomName()); + $this->field = $this->createFileField($this->field_name, $this->type_name); + $this->instance = field_info_instance('node', $this->field_name, $this->type_name); + } + /** * Tests upload and remove buttons for a single-valued File field. */ function testSingleValuedWidget() { - // Use 'page' instead of 'article', so that the 'article' image field does - // not conflict with this test. If in the future the 'page' type gets its - // own default file or image field, this test can be made more robust by - // using a custom node type. - $type_name = 'page'; - $field_name = strtolower($this->randomName()); - $this->createFileField($field_name, $type_name); - $field = field_info_field($field_name); - $instance = field_info_instance('node', $field_name, $type_name); - $test_file = $this->getTestFile('text'); foreach (array('nojs', 'js') as $type) { @@ -352,9 +355,9 @@ class FileFieldWidgetTestCase extends FileFieldTestCase { // successfully. // @todo This only tests a 'nojs' submission, because drupalPostAJAX() // does not yet support file uploads. - $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); + $nid = $this->uploadNodeFile($test_file, $this->field_name, $this->type_name); $node = node_load($nid, NULL, TRUE); - $node_file = (object) $node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]; + $node_file = (object) $node->{$this->field_name}[LANGUAGE_NOT_SPECIFIED][0]; $this->assertFileExists($node_file, t('New file saved to disk on node creation.')); // Ensure the file can be downloaded. @@ -384,7 +387,7 @@ class FileFieldWidgetTestCase extends FileFieldTestCase { // Save the node and ensure it does not have the file. $this->drupalPost(NULL, array(), t('Save')); $node = node_load($nid, NULL, TRUE); - $this->assertTrue(empty($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']), t('File was successfully removed from the node.')); + $this->assertTrue(empty($node->{$this->field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']), t('File was successfully removed from the node.')); } } @@ -392,21 +395,13 @@ class FileFieldWidgetTestCase extends FileFieldTestCase { * Tests upload and remove buttons for multiple multi-valued File fields. */ function testMultiValuedWidget() { - // Use 'page' instead of 'article', so that the 'article' image field does - // not conflict with this test. If in the future the 'page' type gets its - // own default file or image field, this test can be made more robust by - // using a custom node type. - $type_name = 'page'; - $field_name = strtolower($this->randomName()); - $field_name2 = strtolower($this->randomName()); - $this->createFileField($field_name, $type_name, array('cardinality' => 3)); - $this->createFileField($field_name2, $type_name, array('cardinality' => 3)); - - $field = field_info_field($field_name); - $instance = field_info_instance('node', $field_name, $type_name); + $this->field['cardinality'] = 3; + field_update_field($this->field); + $field_name2 = strtolower($this->randomName()); + $this->createFileField($field_name2, $this->type_name, array('cardinality' => 3)); $field2 = field_info_field($field_name2); - $instance2 = field_info_instance('node', $field_name2, $type_name); + $instance2 = field_info_instance('node', $field_name2, $this->type_name); $test_file = $this->getTestFile('text'); @@ -419,8 +414,8 @@ class FileFieldWidgetTestCase extends FileFieldTestCase { // @todo This is only testing a non-Ajax upload, because drupalPostAJAX() // does not yet emulate jQuery's file upload. // - $this->drupalGet("node/add/$type_name"); - foreach (array($field_name2, $field_name) as $each_field_name) { + $this->drupalGet("node/add/$this->type_name"); + foreach (array($field_name2, $this->field_name) as $each_field_name) { for ($delta = 0; $delta < 3; $delta++) { $edit = array('files[' . $each_field_name . '_' . LANGUAGE_NOT_SPECIFIED . '_' . $delta . ']' => drupal_realpath($test_file->uri)); // If the Upload button doesn't exist, drupalPost() will automatically @@ -432,7 +427,7 @@ class FileFieldWidgetTestCase extends FileFieldTestCase { $num_expected_remove_buttons = 6; - foreach (array($field_name, $field_name2) as $current_field_name) { + foreach (array($this->field_name, $field_name2) as $current_field_name) { // How many uploaded files for the current field are remaining. $remaining = 3; // Test clicking each "Remove" button. For extra robustness, test them out @@ -449,8 +444,8 @@ class FileFieldWidgetTestCase extends FileFieldTestCase { foreach ($buttons as $i => $button) { $key = $i >= $remaining ? $i - $remaining : $i; $check_field_name = $field_name2; - if ($current_field_name == $field_name && $i < $remaining) { - $check_field_name = $field_name; + if ($current_field_name == $this->field_name && $i < $remaining) { + $check_field_name = $this->field_name; } $this->assertIdentical((string) $button['name'], $check_field_name . '_' . LANGUAGE_NOT_SPECIFIED . '_' . $key. '_remove_button'); @@ -491,7 +486,7 @@ class FileFieldWidgetTestCase extends FileFieldTestCase { // Ensure only at most one button per field is displayed. $buttons = $this->xpath('//input[@type="submit" and @value="Upload"]'); - $expected = $current_field_name == $field_name ? 1 : 2; + $expected = $current_field_name == $this->field_name ? 1 : 2; $this->assertTrue(is_array($buttons) && count($buttons) == $expected, t('After removing a file, only one "Upload" button for each possible field is displayed (JSMode=%type).', array('%type' => $type))); } } @@ -505,7 +500,7 @@ class FileFieldWidgetTestCase extends FileFieldTestCase { preg_match('/node\/([0-9]+)/', $this->getUrl(), $matches); $nid = $matches[1]; $node = node_load($nid, NULL, TRUE); - $this->assertTrue(empty($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']), t('Node was successfully saved without any files.')); + $this->assertTrue(empty($node->{$this->field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']), t('Node was successfully saved without any files.')); } } @@ -513,24 +508,14 @@ class FileFieldWidgetTestCase extends FileFieldTestCase { * Tests a file field with a "Private files" upload destination setting. */ function testPrivateFileSetting() { - // Use 'page' instead of 'article', so that the 'article' image field does - // not conflict with this test. If in the future the 'page' type gets its - // own default file or image field, this test can be made more robust by - // using a custom node type. - $type_name = 'page'; - $field_name = strtolower($this->randomName()); - $this->createFileField($field_name, $type_name); - $field = field_info_field($field_name); - $instance = field_info_instance('node', $field_name, $type_name); - $test_file = $this->getTestFile('text'); // Change the field setting to make its files private, and upload a file. $edit = array('field[settings][uri_scheme]' => 'private'); - $this->drupalPost("admin/structure/types/manage/$type_name/fields/$field_name", $edit, t('Save settings')); - $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); + $this->drupalPost("admin/structure/types/manage/$this->type_name/fields/$this->field_name", $edit, t('Save settings')); + $nid = $this->uploadNodeFile($test_file, $this->field_name, $this->type_name); $node = node_load($nid, NULL, TRUE); - $node_file = (object) $node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]; + $node_file = (object) $node->{$this->field_name}[LANGUAGE_NOT_SPECIFIED][0]; $this->assertFileExists($node_file, t('New file saved to disk on node creation.')); // Ensure the private file is available to the user who uploaded it. @@ -539,12 +524,12 @@ class FileFieldWidgetTestCase extends FileFieldTestCase { // Ensure we can't change 'uri_scheme' field settings while there are some // entities with uploaded files. - $this->drupalGet("admin/structure/types/manage/$type_name/fields/$field_name"); + $this->drupalGet("admin/structure/types/manage/$this->type_name/fields/$this->field_name"); $this->assertFieldByXpath('//input[@id="edit-field-settings-uri-scheme-public" and @disabled="disabled"]', 'public', t('Upload destination setting disabled.')); // Delete node and confirm that setting could be changed. node_delete($nid); - $this->drupalGet("admin/structure/types/manage/$type_name/fields/$field_name"); + $this->drupalGet("admin/structure/types/manage/$this->type_name/fields/$this->field_name"); $this->assertFieldByXpath('//input[@id="edit-field-settings-uri-scheme-public" and not(@disabled)]', 'public', t('Upload destination setting enabled.')); } @@ -1150,8 +1135,8 @@ class FilePrivateTestCase extends FileFieldTestCase { ); } - function setUp() { - parent::setUp('node_access_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('node_access_test'); node_access_rebuild(); variable_set('node_access_test_private', TRUE); } diff --git a/core/modules/filter/filter.test b/core/modules/filter/filter.test index 923a047..ad76ed7 100644 --- a/core/modules/filter/filter.test +++ b/core/modules/filter/filter.test @@ -20,8 +20,8 @@ class FilterCRUDTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('filter_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('filter_test'); } /** @@ -174,8 +174,8 @@ class FilterAdminTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); // Create users. $filtered_html_format = filter_format_load('filtered_html'); @@ -433,8 +433,8 @@ class FilterFormatAccessTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); @@ -757,8 +757,8 @@ class FilterSecurityTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('node', 'php', 'filter_test')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('node', 'php', 'filter_test')); // Create Basic page node type. $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); @@ -1814,8 +1814,8 @@ class FilterHooksTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('block', 'filter_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('block', 'filter_test'); $admin_user = $this->drupalCreateUser(array('administer filters', 'administer blocks')); $this->drupalLogin($admin_user); } diff --git a/core/modules/forum/forum.test b/core/modules/forum/forum.test index 4561092..6b0b78e 100644 --- a/core/modules/forum/forum.test +++ b/core/modules/forum/forum.test @@ -29,8 +29,8 @@ class ForumTestCase extends WebTestBase { /** * Enable modules and create users with specific permissions. */ - function setUp() { - parent::setUp(array('taxonomy', 'comment', 'forum', 'node', 'block', 'menu', 'help')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('taxonomy', 'comment', 'forum', 'node', 'block', 'menu', 'help')); // Create users. $this->admin_user = $this->drupalCreateUser(array( 'access administration pages', @@ -605,8 +605,8 @@ class ForumIndexTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('taxonomy', 'comment', 'forum'); + function setUpBeforeClass() { + parent::setUpBeforeClass('taxonomy', 'comment', 'forum'); // Create a test user. $web_user = $this->drupalCreateUser(array('create forum content', 'edit own forum content', 'edit any forum content', 'administer nodes')); diff --git a/core/modules/help/help.test b/core/modules/help/help.test index 2621431..c8e5307 100644 --- a/core/modules/help/help.test +++ b/core/modules/help/help.test @@ -32,8 +32,8 @@ class HelpTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('poll'); + function setUpBeforeClass() { + parent::setUpBeforeClass('poll'); $this->getModuleList(); @@ -124,9 +124,9 @@ class NoHelpTestCase extends WebTestBase { ); } - function setUp() { + function setUpBeforeClass() { // Use one of the test modules that do not implement hook_help(). - parent::setUp('menu_test'); + parent::setUpBeforeClass('menu_test'); $this->big_user = $this->drupalCreateUser(array('access administration pages')); } diff --git a/core/modules/image/image.test b/core/modules/image/image.test index f9a4ec1..93abdc9 100644 --- a/core/modules/image/image.test +++ b/core/modules/image/image.test @@ -34,14 +34,14 @@ use Drupal\simpletest\UnitTestBase; class ImageFieldTestCase extends WebTestBase { protected $admin_user; - function setUp() { + function setUpBeforeClass() { $modules = func_get_args(); if (isset($modules[0]) && is_array($modules[0])) { $modules = $modules[0]; } $modules[] = 'node'; $modules[] = 'image'; - parent::setUp($modules); + parent::setUpBeforeClass($modules); // Create Basic page and Article node types. if ($this->profile != 'standard') { @@ -50,6 +50,9 @@ class ImageFieldTestCase extends WebTestBase { } $this->admin_user = $this->drupalCreateUser(array('access content', 'access administration pages', 'administer site configuration', 'administer content types', 'administer nodes', 'create article content', 'edit any article content', 'delete any article content', 'administer image styles')); + } + + function setUp() { $this->drupalLogin($this->admin_user); } @@ -134,8 +137,8 @@ class ImageStylesPathAndUrlUnitTest extends WebTestBase { ); } - function setUp() { - parent::setUp(array('image', 'image_module_test')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('image', 'image_module_test')); $this->style_name = 'style_foo'; image_style_save(array('name' => $this->style_name)); @@ -247,8 +250,8 @@ class ImageEffectsUnitTest extends ImageToolkitTestCase { ); } - function setUp() { - parent::setUp('image_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('image_test'); module_load_include('inc', 'image', 'image.effects'); } @@ -602,8 +605,8 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase { ); } - function setUp() { - parent::setUp(array('field_ui')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('field_ui')); } /** @@ -915,8 +918,8 @@ class ImageDimensionsUnitTest extends WebTestBase { ); } - function setUp() { - parent::setUp(array('image', 'image_module_test')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('image', 'image_module_test')); } /** @@ -1278,8 +1281,8 @@ class ImageFieldDefaultImagesTestCase extends ImageFieldTestCase { ); } - function setUp() { - parent::setUp(array('field_ui')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('field_ui')); } /** diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php index 1e5f430..f71d7f2 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php @@ -21,8 +21,8 @@ class LanguageConfigurationTest extends WebTestBase { ); } - function setUp() { - parent::setUp('language'); + function setUpBeforeClass() { + parent::setUpBeforeClass('language'); } /** diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageDependencyInjectionTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageDependencyInjectionTest.php index e000531..630e57f 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageDependencyInjectionTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageDependencyInjectionTest.php @@ -23,8 +23,8 @@ class LanguageDependencyInjectionTest extends WebTestBase { ); } - function setUp() { - parent::setUp('language'); + function setUpBeforeClass() { + parent::setUpBeforeClass('language'); // Set up a new container to ensure we are building a new Language object // for each test. diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php index 7346bfc..f5fe376 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php @@ -21,8 +21,8 @@ class LanguageListTest extends WebTestBase { ); } - function setUp() { - parent::setUp('language'); + function setUpBeforeClass() { + parent::setUpBeforeClass('language'); } /** diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php index d7d68e4..54cff6c 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php @@ -22,8 +22,8 @@ class LanguageNegotiationInfoTest extends WebTestBase { ); } - function setUp() { - parent::setUp('language'); + function setUpBeforeClass() { + parent::setUpBeforeClass('language'); require_once DRUPAL_ROOT .'/core/includes/language.inc'; $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'view the administration theme')); $this->drupalLogin($admin_user); diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguagePathMonolingualTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguagePathMonolingualTest.php index 4f80277..5db8c2a 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguagePathMonolingualTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguagePathMonolingualTest.php @@ -21,8 +21,8 @@ class LanguagePathMonolingualTest extends WebTestBase { ); } - function setUp() { - parent::setUp('path', 'language'); + function setUpBeforeClass() { + parent::setUpBeforeClass('path', 'language'); // Create and login user. $web_user = $this->drupalCreateUser(array('administer languages', 'access administration pages')); diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php index c8c6732..8c0c9c1 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php @@ -22,8 +22,8 @@ class LanguageSwitchingTest extends WebTestBase { ); } - function setUp() { - parent::setUp(array('language', 'block')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('language', 'block')); // Create and login user. $admin_user = $this->drupalCreateUser(array('administer blocks', 'administer languages', 'access administration pages')); diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php index 5958ac8..e389604 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php @@ -44,11 +44,11 @@ class LanguageUILanguageNegotiationTest extends WebTestBase { ); } - function setUp() { + function setUpBeforeClass() { // We marginally use interface translation functionality here, so need to // use the locale module instead of language only, but the 90% of the test // is about the negotiation process which is solely in language module. - parent::setUp(array('locale', 'language_test', 'block')); + parent::setUpBeforeClass(array('locale', 'language_test', 'block')); require_once DRUPAL_ROOT . '/core/includes/language.inc'; drupal_load('module', 'locale'); $admin_user = $this->drupalCreateUser(array('administer languages', 'translate interface', 'access administration pages', 'administer blocks')); diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php index 137bba9..fb05d00 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php @@ -21,8 +21,8 @@ class LanguageUrlRewritingTest extends WebTestBase { ); } - function setUp() { - parent::setUp('language'); + function setUpBeforeClass() { + parent::setUpBeforeClass('language'); // Create and login user. $this->web_user = $this->drupalCreateUser(array('administer languages', 'access administration pages')); diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleCommentLanguageTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleCommentLanguageTest.php index 16fc83f..2ba237f 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleCommentLanguageTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleCommentLanguageTest.php @@ -23,11 +23,11 @@ class LocaleCommentLanguageTest extends WebTestBase { ); } - function setUp() { + function setUpBeforeClass() { // We also use language_test module here to be able to turn on content // language negotiation. Drupal core does not provide a way in itself // to do that. - parent::setUp('locale', 'language_test'); + parent::setUpBeforeClass('locale', 'language_test'); // Create and login user. $admin_user = $this->drupalCreateUser(array('administer site configuration', 'administer languages', 'access administration pages', 'administer content types', 'create article content')); diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleContentTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleContentTest.php index 0c5cea3..1241949 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleContentTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleContentTest.php @@ -23,8 +23,8 @@ class LocaleContentTest extends WebTestBase { ); } - function setUp() { - parent::setUp('locale'); + function setUpBeforeClass() { + parent::setUpBeforeClass('locale'); } /** diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleDateFormatsTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleDateFormatsTest.php index e5514b8..dff6c56 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleDateFormatsTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleDateFormatsTest.php @@ -22,8 +22,8 @@ class LocaleDateFormatsTest extends WebTestBase { ); } - function setUp() { - parent::setUp(array('node', 'locale')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('node', 'locale')); // Create Article node type. $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleExportTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleExportTest.php index 4ad9356..1c0afbc 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleExportTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleExportTest.php @@ -26,8 +26,8 @@ class LocaleExportTest extends WebTestBase { */ protected $admin_user = NULL; - function setUp() { - parent::setUp('locale'); + function setUpBeforeClass() { + parent::setUpBeforeClass('locale'); $this->admin_user = $this->drupalCreateUser(array('administer languages', 'translate interface', 'access administration pages')); $this->drupalLogin($this->admin_user); diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php index 3beee64..c95c57a 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php @@ -26,8 +26,8 @@ class LocaleImportFunctionalTest extends WebTestBase { */ protected $admin_user = NULL; - function setUp() { - parent::setUp(array('locale', 'dblog')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('locale', 'dblog')); // Set the translation file directory. variable_set('locale_translate_file_directory', drupal_get_path('module', 'locale') . '/tests'); diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleInstallTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleInstallTest.php index f1677eb..37136ee 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleInstallTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleInstallTest.php @@ -22,8 +22,8 @@ class LocaleInstallTest extends WebTestBase { ); } - function setUp() { - parent::setUp('locale'); + function setUpBeforeClass() { + parent::setUpBeforeClass('locale'); // st() lives in install.inc, so ensure that it is loaded for all tests. require_once DRUPAL_ROOT . '/core/includes/install.inc'; diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleJavascriptTranslation.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleJavascriptTranslation.php index 9739537..8a56c58 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleJavascriptTranslation.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleJavascriptTranslation.php @@ -21,8 +21,8 @@ class LocaleJavascriptTranslation extends WebTestBase { ); } - function setUp() { - parent::setUp('locale'); + function setUpBeforeClass() { + parent::setUpBeforeClass('locale'); } function testFileParsing() { diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleMultilingualFieldsTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleMultilingualFieldsTest.php index 2a8299a..fb09f78 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleMultilingualFieldsTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleMultilingualFieldsTest.php @@ -21,8 +21,8 @@ class LocaleMultilingualFieldsTest extends WebTestBase { ); } - function setUp() { - parent::setUp(array('node', 'locale')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('node', 'locale')); // Create Basic page node type. $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php index 61fd67f..b02c558 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php @@ -21,8 +21,8 @@ class LocalePathTest extends WebTestBase { ); } - function setUp() { - parent::setUp(array('node', 'locale', 'path')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('node', 'locale', 'path')); $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); variable_set('site_frontpage', 'node'); diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocalePluralFormatTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocalePluralFormatTest.php index 6d45d21..39a56dd 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocalePluralFormatTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocalePluralFormatTest.php @@ -21,8 +21,8 @@ class LocalePluralFormatTest extends WebTestBase { ); } - function setUp() { - parent::setUp('locale'); + function setUpBeforeClass() { + parent::setUpBeforeClass('locale'); $admin_user = $this->drupalCreateUser(array('administer languages', 'translate interface', 'access administration pages')); $this->drupalLogin($admin_user); diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationTest.php index 28e0834..173eff2 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationTest.php @@ -21,8 +21,8 @@ class LocaleTranslationTest extends WebTestBase { ); } - function setUp() { - parent::setUp('locale'); + function setUpBeforeClass() { + parent::setUpBeforeClass('locale'); } /** diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallFrenchTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallFrenchTest.php index 047ff63..c05f9e9 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallFrenchTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallFrenchTest.php @@ -24,8 +24,8 @@ class LocaleUninstallFrenchTest extends LocaleUninstallTest { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); $this->langcode = 'fr'; } } diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php index 72868e9..fa2c413 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php @@ -26,8 +26,8 @@ class LocaleUninstallTest extends WebTestBase { */ protected $language; - function setUp() { - parent::setUp(array('node', 'locale')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('node', 'locale')); $this->langcode = 'en'; // Create Article node type. diff --git a/core/modules/menu/menu.test b/core/modules/menu/menu.test index 14fe96b..8adf6ba 100644 --- a/core/modules/menu/menu.test +++ b/core/modules/menu/menu.test @@ -23,8 +23,8 @@ class MenuTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('menu'); + function setUpBeforeClass() { + parent::setUpBeforeClass('menu'); // Create users. $this->big_user = $this->drupalCreateUser(array('access administration pages', 'administer blocks', 'administer menu', 'create article content')); $this->std_user = $this->drupalCreateUser(array()); @@ -596,8 +596,8 @@ class MenuNodeTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('menu'); + function setUpBeforeClass() { + parent::setUpBeforeClass('menu'); $this->admin_user = $this->drupalCreateUser(array( 'access administration pages', diff --git a/core/modules/node/node.test b/core/modules/node/node.test index 9188bad..81d3f66 100644 --- a/core/modules/node/node.test +++ b/core/modules/node/node.test @@ -9,13 +9,13 @@ use Drupal\simpletest\WebTestBase; */ class NodeWebTestCase extends WebTestBase { - function setUp() { + function setUpBeforeClass() { $modules = func_get_args(); if (isset($modules[0]) && is_array($modules[0])) { $modules = $modules[0]; } $modules[] = 'node'; - parent::setUp($modules); + parent::setUpBeforeClass($modules); // Create Basic page and Article node types. if ($this->profile != 'standard') { @@ -38,8 +38,8 @@ class NodeLoadMultipleUnitTest extends NodeWebTestCase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); $web_user = $this->drupalCreateUser(array('create article content', 'create page content')); $this->drupalLogin($web_user); } @@ -117,8 +117,8 @@ class NodeLoadHooksTestCase extends NodeWebTestCase { ); } - function setUp() { - parent::setUp('node_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('node_test'); } /** @@ -161,8 +161,8 @@ class NodeRevisionsTestCase extends NodeWebTestCase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); // Create and login user. $web_user = $this->drupalCreateUser(array('view revisions', 'revert revisions', 'edit any page content', @@ -306,8 +306,8 @@ class PageEditTestCase extends NodeWebTestCase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); $this->web_user = $this->drupalCreateUser(array('edit own page content', 'create page content')); $this->admin_user = $this->drupalCreateUser(array('bypass node access', 'administer nodes')); @@ -435,8 +435,8 @@ class PagePreviewTestCase extends NodeWebTestCase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); $web_user = $this->drupalCreateUser(array('edit own page content', 'create page content')); $this->drupalLogin($web_user); @@ -506,9 +506,9 @@ class NodeCreationTestCase extends NodeWebTestCase { ); } - function setUp() { + function setUpBeforeClass() { // Enable dummy module that implements hook_node_insert for exceptions. - parent::setUp(array('node_test_exception', 'dblog')); + parent::setUpBeforeClass(array('node_test_exception', 'dblog')); $web_user = $this->drupalCreateUser(array('create page content', 'edit own page content')); $this->drupalLogin($web_user); @@ -699,8 +699,8 @@ class NodeBlockTestCase extends NodeWebTestCase { ); } - function setUp() { - parent::setUp(array('block')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('block')); // Create and login user $admin_user = $this->drupalCreateUser(array('administer blocks')); @@ -732,8 +732,8 @@ class NodePostSettingsTestCase extends NodeWebTestCase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); $web_user = $this->drupalCreateUser(array('create page content', 'administer content types', 'access user profiles')); $this->drupalLogin($web_user); @@ -801,9 +801,9 @@ class NodeRSSContentTestCase extends NodeWebTestCase { ); } - function setUp() { + function setUpBeforeClass() { // Enable dummy module that implements hook_node_view. - parent::setUp('node_test'); + parent::setUpBeforeClass('node_test'); // Use bypass node access permission here, because the test class uses // hook_grants_alter() to deny access to everyone on node_access @@ -872,8 +872,8 @@ class NodeAccessUnitTest extends NodeWebTestCase { } } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); // Clear permissions for authenticated users. db_delete('role_permission') ->condition('rid', DRUPAL_AUTHENTICATED_RID) @@ -929,11 +929,11 @@ class NodeAccessRecordsUnitTest extends NodeWebTestCase { ); } - function setUp() { + function setUpBeforeClass() { // Enable dummy module that implements hook_node_grants(), // hook_node_access_records(), hook_node_grants_alter() and // hook_node_access_records_alter(). - parent::setUp('node_test'); + parent::setUpBeforeClass('node_test'); } /** @@ -1018,8 +1018,8 @@ class NodeAccessBaseTableTestCase extends NodeWebTestCase { /** * Enable modules and create user with specific permissions. */ - public function setUp() { - parent::setUp('node_access_test'); + public function setUpBeforeClass() { + parent::setUpBeforeClass('node_access_test'); node_access_rebuild(); variable_set('node_access_test_private', TRUE); } @@ -1174,8 +1174,8 @@ class NodeSaveTestCase extends NodeWebTestCase { ); } - function setUp() { - parent::setUp('node_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('node_test'); // Create a user that is allowed to post; we'll use this to test the submission. $web_user = $this->drupalCreateUser(array('create article content')); $this->drupalLogin($web_user); @@ -1316,8 +1316,8 @@ class NodeTypeTestCase extends NodeWebTestCase { ); } - function setUp() { - parent::setUp(array('field_ui')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('field_ui')); } /** @@ -1370,6 +1370,45 @@ class NodeTypeTestCase extends NodeWebTestCase { } /** + * Test that node_types_rebuild() correctly handles the 'disabled' flag. + */ + function testNodeTypeStatus() { + // Enable all core node modules, and all types should be active. + module_enable(array('book', 'poll'), FALSE); + node_types_rebuild(); + $types = node_type_get_types(); + foreach (array('book', 'poll', 'article', 'page') as $type) { + $this->assertTrue(isset($types[$type]), t('%type is found in node types.', array('%type' => $type))); + $this->assertTrue(isset($types[$type]->disabled) && empty($types[$type]->disabled), t('%type type is enabled.', array('%type' => $type))); + } + + // Disable poll module and the respective type should be marked as disabled. + module_disable(array('poll'), FALSE); + node_types_rebuild(); + $types = node_type_get_types(); + $this->assertTrue(!empty($types['poll']->disabled), t("Poll module's node type disabled.")); + + // Disable book module and the respective type should still be active, since + // it is not provided by hook_node_info(). + module_disable(array('book'), FALSE); + node_types_rebuild(); + $types = node_type_get_types(); + $this->assertTrue(isset($types['book']) && empty($types['book']->disabled), t("Book module's node type still active.")); + $this->assertTrue(!empty($types['poll']->disabled), t("Poll module's node type still disabled.")); + $this->assertTrue(isset($types['article']) && empty($types['article']->disabled), t("Article node type still active.")); + $this->assertTrue(isset($types['page']) && empty($types['page']->disabled), t("Basic page node type still active.")); + + // Re-enable the modules and verify that the types are active again. + module_enable(array('book', 'poll'), FALSE); + node_types_rebuild(); + $types = node_type_get_types(); + foreach (array('book', 'poll', 'article', 'page') as $type) { + $this->assertTrue(isset($types[$type]), t('%type is found in node types.', array('%type' => $type))); + $this->assertTrue(isset($types[$type]->disabled) && empty($types[$type]->disabled), t('%type type is enabled.', array('%type' => $type))); + } + } + + /** * Test editing a node type using the UI. */ function testNodeTypeEditing() { @@ -1421,45 +1460,6 @@ class NodeTypeTestCase extends NodeWebTestCase { $this->drupalGet('node/add/bar'); $this->assertNoRaw('Body', t('Body field was not found.')); } - - /** - * Test that node_types_rebuild() correctly handles the 'disabled' flag. - */ - function testNodeTypeStatus() { - // Enable all core node modules, and all types should be active. - module_enable(array('book', 'poll'), FALSE); - node_types_rebuild(); - $types = node_type_get_types(); - foreach (array('book', 'poll', 'article', 'page') as $type) { - $this->assertTrue(isset($types[$type]), t('%type is found in node types.', array('%type' => $type))); - $this->assertTrue(isset($types[$type]->disabled) && empty($types[$type]->disabled), t('%type type is enabled.', array('%type' => $type))); - } - - // Disable poll module and the respective type should be marked as disabled. - module_disable(array('poll'), FALSE); - node_types_rebuild(); - $types = node_type_get_types(); - $this->assertTrue(!empty($types['poll']->disabled), t("Poll module's node type disabled.")); - - // Disable book module and the respective type should still be active, since - // it is not provided by hook_node_info(). - module_disable(array('book'), FALSE); - node_types_rebuild(); - $types = node_type_get_types(); - $this->assertTrue(isset($types['book']) && empty($types['book']->disabled), t("Book module's node type still active.")); - $this->assertTrue(!empty($types['poll']->disabled), t("Poll module's node type still disabled.")); - $this->assertTrue(isset($types['article']) && empty($types['article']->disabled), t("Article node type still active.")); - $this->assertTrue(isset($types['page']) && empty($types['page']->disabled), t("Basic page node type still active.")); - - // Re-enable the modules and verify that the types are active again. - module_enable(array('book', 'poll'), FALSE); - node_types_rebuild(); - $types = node_type_get_types(); - foreach (array('book', 'poll', 'article', 'page') as $type) { - $this->assertTrue(isset($types[$type]), t('%type is found in node types.', array('%type' => $type))); - $this->assertTrue(isset($types[$type]->disabled) && empty($types[$type]->disabled), t('%type type is enabled.', array('%type' => $type))); - } - } } /** @@ -1550,8 +1550,8 @@ class NodeAccessRebuildTestCase extends NodeWebTestCase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); $web_user = $this->drupalCreateUser(array('administer site configuration', 'access administration pages', 'access site reports')); $this->drupalLogin($web_user); @@ -1578,8 +1578,8 @@ class NodeAdminTestCase extends NodeWebTestCase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); // Remove the "view own unpublished content" permission which is set // by default for authenticated users so we can test this permission @@ -1745,8 +1745,8 @@ class NodeTitleTestCase extends NodeWebTestCase { ); } - function setUp() { - parent::setUp(array('comment')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('comment')); $this->admin_user = $this->drupalCreateUser(array('administer nodes', 'create article content', 'create page content', 'post comments')); $this->drupalLogin($this->admin_user); } @@ -1818,8 +1818,8 @@ class NodeBlockFunctionalTest extends NodeWebTestCase { ); } - function setUp() { - parent::setUp(array('block')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('block')); // Create users and test node. $this->admin_user = $this->drupalCreateUser(array('administer content types', 'administer nodes', 'administer blocks')); @@ -1954,8 +1954,8 @@ class MultiStepNodeFormBasicOptionsTest extends WebTestBase { ); } - function setUp() { - parent::setUp('poll'); + function setUpBeforeClass() { + parent::setUpBeforeClass('poll'); $web_user = $this->drupalCreateUser(array('administer nodes', 'create poll content')); $this->drupalLogin($web_user); } @@ -2030,8 +2030,8 @@ class NodeQueryAlter extends NodeWebTestCase { */ protected $noAccessUser; - function setUp() { - parent::setUp('node_access_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('node_access_test'); node_access_rebuild(); // Create some content. @@ -2221,8 +2221,8 @@ class NodeEntityFieldQueryAlter extends NodeWebTestCase { */ protected $noAccessUser; - function setUp() { - parent::setUp('node_access_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('node_access_test'); node_access_rebuild(); // Creating 4 nodes with an entity field so we can test that sort of query @@ -2361,8 +2361,8 @@ class NodeRevisionPermissionsTestCase extends NodeWebTestCase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); // Create a node with several revisions. $node = $this->drupalCreateNode(); @@ -2450,8 +2450,8 @@ class NodeAccessPagerTestCase extends WebTestBase { ); } - public function setUp() { - parent::setUp('node_access_test', 'comment', 'forum'); + public function setUpBeforeClass() { + parent::setUpBeforeClass('node_access_test', 'comment', 'forum'); node_access_rebuild(); $this->web_user = $this->drupalCreateUser(array('access content', 'access comments', 'node test view')); } @@ -2536,8 +2536,8 @@ class NodeAccessFieldTestCase extends NodeWebTestCase { ); } - public function setUp() { - parent::setUp('node_access_test', 'field_ui'); + public function setUpBeforeClass() { + parent::setUpBeforeClass('node_access_test', 'field_ui'); node_access_rebuild(); // Create some users. diff --git a/core/modules/openid/openid.test b/core/modules/openid/openid.test index 34e0567..28c700f 100644 --- a/core/modules/openid/openid.test +++ b/core/modules/openid/openid.test @@ -11,14 +11,14 @@ use Drupal\simpletest\WebTestBase; * Base class for OpenID tests. */ abstract class OpenIDWebTestCase extends WebTestBase { - function setUp() { + function setUpBeforeClass() { $modules = func_get_args(); if (isset($modules[0]) && is_array($modules[0])) { $modules = $modules[0]; } $modules[] = 'block'; $modules[] = 'openid'; - parent::setUp($modules); + parent::setUpBeforeClass($modules); // Enable user login block. db_merge('block') @@ -83,13 +83,17 @@ class OpenIDFunctionalTestCase extends OpenIDWebTestCase { ); } - function setUp() { - parent::setUp('openid', 'openid_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('openid_test'); // User doesn't need special permissions; only the ability to log in. $this->web_user = $this->drupalCreateUser(array()); } + function setUp() { + db_truncate('authmap')->execute(); + } + /** * Test discovery of OpenID Provider Endpoint via Yadis and HTML. */ @@ -179,6 +183,10 @@ class OpenIDFunctionalTestCase extends OpenIDWebTestCase { $identity = url('openid-test/redirected/yadis/xrds/3', array('absolute' => TRUE)); $expected_claimed_id = FALSE; $this->addRedirectedIdentity($identity, 2, 'http://example.com/xrds', $expected_claimed_id, 3); + + variable_del('openid_test_response'); + variable_del('xri_proxy_resolver'); + variable_del('openid_test_canonical_id_status'); } /** @@ -234,6 +242,8 @@ class OpenIDFunctionalTestCase extends OpenIDWebTestCase { $this->assertLink(t('Log out'), 0, t('User was logged in.')); $response = variable_get('openid_test_hook_openid_response_response'); $this->assertEqual($response['openid.identity'], $new_identity, t('hook_openid_request_alter() were invoked.')); + + $this->drupalLogout(); } /** @@ -266,6 +276,9 @@ class OpenIDFunctionalTestCase extends OpenIDWebTestCase { // Verify user was redirected away from user/login to an accessible page. $this->assertText(t('Operating in maintenance mode.')); $this->assertResponse(200); + + variable_set('maintenance_mode', 0); + $this->drupalLogout(); } /** @@ -454,10 +467,12 @@ class OpenIDRegistrationTestCase extends OpenIDWebTestCase { ); } - function setUp() { + function setUpBeforeClass() { // Add language module too to test with some non-built-in languages. - parent::setUp('openid', 'openid_test', 'language'); + parent::setUpBeforeClass('openid_test', 'language'); variable_set('user_register', USER_REGISTER_VISITORS); + variable_set('configurable_timezones', 1); + variable_set('date_default_timezone', 'Europe/Brussels'); } /** @@ -465,8 +480,6 @@ class OpenIDRegistrationTestCase extends OpenIDWebTestCase { */ function testRegisterUserWithEmailVerification() { variable_set('user_email_verification', TRUE); - variable_get('configurable_timezones', 1); - variable_set('date_default_timezone', 'Europe/Brussels'); // Tell openid_test.module to respond with these SREG fields. variable_set('openid_test_response', array( @@ -515,6 +528,9 @@ class OpenIDRegistrationTestCase extends OpenIDWebTestCase { // Verify that the account was activated. $this->submitLoginForm($identity); $this->assertLink(t('Log out'), 0, t('User was logged in.')); + + $this->drupalLogout(); + user_delete($user->uid); } /** @@ -522,8 +538,6 @@ class OpenIDRegistrationTestCase extends OpenIDWebTestCase { */ function testRegisterUserWithoutEmailVerification() { variable_set('user_email_verification', FALSE); - variable_get('configurable_timezones', 1); - variable_set('date_default_timezone', 'Europe/Brussels'); // Tell openid_test.module to respond with these SREG fields. variable_set('openid_test_response', array( @@ -556,6 +570,9 @@ class OpenIDRegistrationTestCase extends OpenIDWebTestCase { $this->submitLoginForm($identity); $this->assertLink(t('Log out'), 0, t('User was logged in.')); + + $this->drupalLogout(); + user_delete($user->uid); } /** @@ -563,8 +580,7 @@ class OpenIDRegistrationTestCase extends OpenIDWebTestCase { * information (a username that is already taken, and no e-mail address). */ function testRegisterUserWithInvalidSreg() { - variable_get('configurable_timezones', 1); - variable_set('date_default_timezone', 'Europe/Brussels'); + variable_set('user_email_verification', TRUE); // Tell openid_test.module to respond with these SREG fields. $web_user = $this->drupalCreateUser(array()); @@ -607,6 +623,9 @@ class OpenIDRegistrationTestCase extends OpenIDWebTestCase { $this->clickLink(t('OpenID identities')); $this->assertRaw($identity, t('OpenID identity was registered.')); + + $this->drupalLogout(); + user_delete($user->uid); } /** @@ -614,8 +633,6 @@ class OpenIDRegistrationTestCase extends OpenIDWebTestCase { * information (i.e. no username or e-mail address). */ function testRegisterUserWithoutSreg() { - variable_get('configurable_timezones', 1); - // Load the front page to get the user login block. $this->drupalGet(''); @@ -646,6 +663,9 @@ class OpenIDRegistrationTestCase extends OpenIDWebTestCase { $this->clickLink(t('OpenID identities')); $this->assertRaw($identity, t('OpenID identity was registered.')); + + $this->drupalLogout(); + user_delete($user->uid); } /** @@ -654,7 +674,6 @@ class OpenIDRegistrationTestCase extends OpenIDWebTestCase { */ function testRegisterUserWithAXButNoSREG() { variable_set('user_email_verification', FALSE); - variable_set('date_default_timezone', 'Europe/Brussels'); // Tell openid_test.module to respond with these AX fields. variable_set('openid_test_response', array( @@ -691,6 +710,9 @@ class OpenIDRegistrationTestCase extends OpenIDWebTestCase { $this->assertEqual($user->mail, 'john@example.com', t('User was registered with right email address.')); $this->assertEqual($user->timezone, 'Europe/London', t('User was registered with right timezone.')); $this->assertEqual($user->preferred_langcode, 'pt-pt', t('User was registered with right language.')); + + $this->drupalLogout(); + user_delete($user->uid); } } @@ -706,8 +728,8 @@ class OpenIDUnitTest extends WebTestBase { ); } - function setUp() { - parent::setUp('openid'); + function setUpBeforeClass() { + parent::setUpBeforeClass('openid'); module_load_include('inc', 'openid'); } diff --git a/core/modules/path/path.test b/core/modules/path/path.test index c742ad5..4af680c 100644 --- a/core/modules/path/path.test +++ b/core/modules/path/path.test @@ -11,14 +11,14 @@ use Drupal\simpletest\WebTestBase; * Provides a base class for testing the Path module. */ class PathTestCase extends WebTestBase { - function setUp() { + function setUpBeforeClass() { $modules = func_get_args(); if (isset($modules[0]) && is_array($modules[0])) { $modules = $modules[0]; } $modules[] = 'node'; $modules[] = 'path'; - parent::setUp($modules); + parent::setUpBeforeClass($modules); // Create Basic page and Article node types. if ($this->profile != 'standard') { @@ -40,8 +40,8 @@ class PathAliasTestCase extends PathTestCase { ); } - function setUp() { - parent::setUp('path'); + function setUpBeforeClass() { + parent::setUpBeforeClass('path'); // Create test user and login. $web_user = $this->drupalCreateUser(array('create page content', 'edit own page content', 'administer url aliases', 'create url aliases')); @@ -240,8 +240,8 @@ class PathTaxonomyTermTestCase extends PathTestCase { ); } - function setUp() { - parent::setUp(array('taxonomy')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('taxonomy')); // Create a Tags vocabulary for the Article node type. $vocabulary = entity_create('taxonomy_vocabulary', array( @@ -311,8 +311,8 @@ class PathLanguageTestCase extends PathTestCase { ); } - function setUp() { - parent::setUp('path', 'locale', 'translation'); + function setUpBeforeClass() { + parent::setUpBeforeClass('path', 'locale', 'translation'); // Create and login user. $this->web_user = $this->drupalCreateUser(array('edit any page content', 'create page content', 'administer url aliases', 'create url aliases', 'administer languages', 'translate content', 'access administration pages')); @@ -454,8 +454,8 @@ class PathLanguageUITestCase extends PathTestCase { ); } - function setUp() { - parent::setUp('path', 'locale'); + function setUpBeforeClass() { + parent::setUpBeforeClass('path', 'locale'); // Create and login user. $web_user = $this->drupalCreateUser(array('edit any page content', 'create page content', 'administer url aliases', 'create url aliases', 'administer languages', 'access administration pages')); diff --git a/core/modules/php/php.test b/core/modules/php/php.test index 7f86ecc..beeb53b 100644 --- a/core/modules/php/php.test +++ b/core/modules/php/php.test @@ -13,8 +13,8 @@ use Drupal\simpletest\WebTestBase; class PHPTestCase extends WebTestBase { protected $php_code_format; - function setUp() { - parent::setUp('php'); + function setUpBeforeClass() { + parent::setUpBeforeClass('php'); // Create Basic page node type. $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); diff --git a/core/modules/poll/poll.test b/core/modules/poll/poll.test index b43c4073..e57a20c 100644 --- a/core/modules/poll/poll.test +++ b/core/modules/poll/poll.test @@ -8,14 +8,14 @@ use Drupal\simpletest\WebTestBase; class PollWebTestCase extends WebTestBase { - function setUp() { + function setUpBeforeClass() { $modules = func_get_args(); if (isset($modules[0]) && is_array($modules[0])) { $modules = $modules[0]; } $modules[] = 'node'; $modules[] = 'poll'; - parent::setUp($modules); + parent::setUpBeforeClass($modules); } /** @@ -275,7 +275,7 @@ class PollCreateTestCase extends PollWebTestCase { // Vote on the poll. $this->drupalLogout(); $this->drupalLogin($vote_user); - $vote_edit = array('choice' => '1'); + $vote_edit = array('choice' => 10); $this->drupalPost('node/' . $poll_nid, $vote_edit, t('Vote')); $this->assertText('Your vote was recorded.', 'Your vote was recorded.'); $elements = $this->xpath('//input[@value="Cancel your vote"]'); @@ -303,10 +303,6 @@ class PollVoteTestCase extends PollWebTestCase { ); } - function tearDown() { - parent::tearDown(); - } - function testPollVote() { $title = $this->randomName(); $choices = $this->_generateChoices(7); @@ -375,8 +371,8 @@ class PollBlockTestCase extends PollWebTestCase { ); } - function setUp() { - parent::setUp(array('block')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('block')); // Create and login user $admin_user = $this->drupalCreateUser(array('administer blocks')); @@ -446,8 +442,8 @@ class PollJSAddChoice extends WebTestBase { ); } - function setUp() { - parent::setUp(array('poll')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('poll')); } /** @@ -483,8 +479,8 @@ class PollVoteCheckHostname extends PollWebTestCase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); // Create and login user. $this->admin_user = $this->drupalCreateUser(array('administer permissions', 'create poll content')); @@ -804,8 +800,8 @@ class PollTranslateTestCase extends PollWebTestCase { ); } - function setUp() { - parent::setUp(array('translation')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('translation')); } /** diff --git a/core/modules/rdf/rdf.test b/core/modules/rdf/rdf.test index 564408e..56aba13 100644 --- a/core/modules/rdf/rdf.test +++ b/core/modules/rdf/rdf.test @@ -18,8 +18,8 @@ class RdfMappingHookTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('rdf', 'rdf_test', 'field_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('rdf', 'rdf_test', 'field_test'); } /** @@ -56,8 +56,8 @@ class RdfRdfaMarkupTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('rdf', 'field_test', 'rdf_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('rdf', 'field_test', 'rdf_test'); } /** @@ -223,8 +223,8 @@ class RdfCrudTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('rdf', 'rdf_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('rdf', 'rdf_test'); } /** @@ -293,8 +293,8 @@ class RdfMappingDefinitionTestCase extends TaxonomyWebTestCase { ); } - function setUp() { - parent::setUp('rdf', 'rdf_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('rdf', 'rdf_test'); } /** @@ -427,8 +427,8 @@ class RdfCommentAttributesTestCase extends CommentTestBase { ); } - public function setUp() { - parent::setUp('comment', 'rdf', 'rdf_test'); + public function setUpBeforeClass() { + parent::setUpBeforeClass('comment', 'rdf', 'rdf_test'); $this->admin_user = $this->drupalCreateUser(array('administer content types', 'administer comments', 'administer permissions', 'administer blocks')); $this->web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'create article content', 'access user profiles')); @@ -591,8 +591,8 @@ class RdfTrackerAttributesTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('rdf', 'rdf_test', 'tracker'); + function setUpBeforeClass() { + parent::setUpBeforeClass('rdf', 'rdf_test', 'tracker'); // Enable anonymous posting of content. user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array( 'create article content' => TRUE, @@ -706,8 +706,8 @@ class RdfGetRdfNamespacesTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('rdf', 'rdf_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('rdf', 'rdf_test'); } /** @@ -736,8 +736,8 @@ class DrupalGetRdfNamespacesTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('rdf', 'rdf_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('rdf', 'rdf_test'); } /** diff --git a/core/modules/search/search.test b/core/modules/search/search.test index 619055c..d0fdd06 100644 --- a/core/modules/search/search.test +++ b/core/modules/search/search.test @@ -15,7 +15,7 @@ use Drupal\simpletest\WebTestBase; use Drupal\simpletest\UnitTestBase; class SearchWebTestCase extends WebTestBase { - function setUp() { + function setUpBeforeClass() { $modules = func_get_args(); if (isset($modules[0]) && is_array($modules[0])) { $modules = $modules[0]; @@ -23,7 +23,7 @@ class SearchWebTestCase extends WebTestBase { $modules[] = 'node'; $modules[] = 'search'; $modules[] = 'dblog'; - parent::setUp($modules); + parent::setUpBeforeClass($modules); // Create Basic page and Article node types. if ($this->profile != 'standard') { @@ -269,8 +269,8 @@ class SearchPageText extends SearchWebTestCase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); // Create user. $this->searching_user = $this->drupalCreateUser(array('search content', 'access user profiles')); @@ -333,8 +333,8 @@ class SearchAdvancedSearchForm extends SearchWebTestCase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); // Create and login user. $test_user = $this->drupalCreateUser(array('access content', 'search content', 'use advanced search', 'administer nodes')); $this->drupalLogin($test_user); @@ -394,8 +394,8 @@ class SearchRankingTestCase extends SearchWebTestCase { ); } - function setUp() { - parent::setUp(array('statistics', 'comment')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('statistics', 'comment')); } function testRankings() { @@ -614,8 +614,8 @@ class SearchBlockTestCase extends SearchWebTestCase { ); } - function setUp() { - parent::setUp(array('block')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('block')); // Create and login user $admin_user = $this->drupalCreateUser(array('administer blocks', 'search content')); @@ -755,8 +755,8 @@ class SearchCommentTestCase extends SearchWebTestCase { ); } - function setUp() { - parent::setUp(array('comment')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('comment')); // Create and log in an administrative user having access to the Full HTML // text format. @@ -770,6 +770,9 @@ class SearchCommentTestCase extends SearchWebTestCase { 'access comments', ); $this->admin_user = $this->drupalCreateUser($permissions); + } + + function setUp() { $this->drupalLogin($this->admin_user); } @@ -983,9 +986,9 @@ class SearchExpressionInsertExtractTestCase extends UnitTestBase { ); } - function setUp() { + function setUpBeforeClass() { drupal_load('module', 'search'); - parent::setUp(); + parent::setUpBeforeClass(); } /** @@ -1055,8 +1058,8 @@ class SearchCommentCountToggleTestCase extends SearchWebTestCase { ); } - function setUp() { - parent::setUp(array('comment')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('comment')); // Create searching user. $this->searching_user = $this->drupalCreateUser(array('search content', 'access content', 'access comments', 'skip comment approval')); @@ -1220,8 +1223,8 @@ class SearchKeywordsConditions extends SearchWebTestCase { ); } - function setUp() { - parent::setUp(array('comment', 'search_extra_type')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('comment', 'search_extra_type')); // Create searching user. $this->searching_user = $this->drupalCreateUser(array('search content', 'access content', 'access comments', 'skip comment approval')); // Login with sufficient privileges. @@ -1274,8 +1277,8 @@ class SearchNumbersTestCase extends SearchWebTestCase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); $this->test_user = $this->drupalCreateUser(array('search content', 'access content', 'administer nodes', 'access site reports')); $this->drupalLogin($this->test_user); @@ -1362,8 +1365,8 @@ class SearchNumberMatchingTestCase extends SearchWebTestCase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); $this->test_user = $this->drupalCreateUser(array('search content', 'access content', 'administer nodes', 'access site reports')); $this->drupalLogin($this->test_user); @@ -1444,8 +1447,8 @@ class SearchConfigSettingsForm extends SearchWebTestCase { ); } - function setUp() { - parent::setUp(array('block', 'search_extra_type')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('block', 'search_extra_type')); // Login as a user that can create and search content. $this->search_user = $this->drupalCreateUser(array('search content', 'administer search', 'administer nodes', 'bypass node access', 'access user profiles', 'administer users', 'administer blocks')); @@ -1601,9 +1604,9 @@ class SearchExcerptTestCase extends UnitTestBase { ); } - function setUp() { + function setUpBeforeClass() { drupal_load('module', 'search'); - parent::setUp(); + parent::setUpBeforeClass(); } /** @@ -1862,8 +1865,8 @@ class SearchEmbedForm extends SearchWebTestCase { ); } - function setUp() { - parent::setUp(array('search_embedded_form')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('search_embedded_form')); // Create a user and a node, and update the search index. $test_user = $this->drupalCreateUser(array('access content', 'search content', 'administer nodes')); @@ -1930,8 +1933,8 @@ class SearchPageOverride extends SearchWebTestCase { ); } - function setUp() { - parent::setUp(array('search_extra_type')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('search_extra_type')); // Login as a user that can create and search content. $this->search_user = $this->drupalCreateUser(array('search content', 'administer search')); @@ -1962,8 +1965,8 @@ class SearchLanguageTestCase extends SearchWebTestCase { ); } - function setUp() { - parent::setUp(array('locale')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('locale')); // Create and login user. $test_user = $this->drupalCreateUser(array('access content', 'search content', 'use advanced search', 'administer nodes', 'administer languages', 'access administration pages')); @@ -2024,8 +2027,8 @@ class SearchNodeAccessTest extends SearchWebTestCase { ); } - function setUp() { - parent::setUp(array('node_access_test')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('node_access_test')); node_access_rebuild(); // Create a test user and log in. diff --git a/core/modules/shortcut/shortcut.test b/core/modules/shortcut/shortcut.test index 815b732..2988c63 100644 --- a/core/modules/shortcut/shortcut.test +++ b/core/modules/shortcut/shortcut.test @@ -32,8 +32,8 @@ class ShortcutTestCase extends WebTestBase { */ protected $set; - function setUp() { - parent::setUp('toolbar', 'shortcut'); + function setUpBeforeClass() { + parent::setUpBeforeClass('toolbar', 'shortcut'); // Create Basic page and Article node types. if ($this->profile != 'standard') { diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php index 552b4e3..4440de8 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php @@ -9,6 +9,7 @@ namespace Drupal\simpletest; use Drupal\Core\Database\Database; use Drupal\Core\Database\ConnectionNotDefinedException; +use ReflectionClass; use ReflectionMethod; use ReflectionObject; @@ -77,11 +78,11 @@ abstract class TestBase { /** * Flag to indicate whether the test has been set up. * - * The setUp() method isolates the test from the parent Drupal site by + * The setUpBeforeClass() method isolates the test from the parent Drupal site by * creating a random prefix for the database and setting up a clean file - * storage directory. The tearDown() method then cleans up this test - * environment. We must ensure that setUp() has been run. Otherwise, - * tearDown() will act on the parent Drupal site rather than the test + * storage directory. The tearDownAfterClass() method then cleans up this test + * environment. We must ensure that setUpBeforeClass() has been run. Otherwise, + * tearDownAfterClass() will act on the parent Drupal site rather than the test * environment, destroying live data. */ protected $setup = FALSE; @@ -150,15 +151,7 @@ abstract class TestBase { ); // Store assertion for display after the test has completed. - try { - $connection = Database::getConnection('default', 'simpletest_original_default'); - } - catch (ConnectionNotDefinedException $e) { - // If the test was not set up, the simpletest_original_default - // connection does not exist. - $connection = Database::getConnection('default', 'default'); - } - $connection + TestBase::getOriginalDatabaseConnection() ->insert('simpletest') ->fields($assertion) ->execute(); @@ -174,6 +167,21 @@ abstract class TestBase { } /** + * Returns the original database connections; i.e., the one of the test runner. + */ + public static function getOriginalDatabaseConnection() { + try { + $connection = Database::getConnection('default', 'simpletest_original_default'); + } + catch (ConnectionNotDefinedException $e) { + // If the test was not set up, the simpletest_original_default + // connection does not exist. + $connection = Database::getConnection('default', 'default'); + } + return $connection; + } + + /** * Store an assertion from outside the testing context. * * This is useful for inserting assertions that can only be recorded after @@ -212,7 +220,8 @@ abstract class TestBase { 'file' => $caller['file'], ); - return db_insert('simpletest') + return TestBase::getOriginalDatabaseConnection() + ->insert('simpletest') ->fields($assertion) ->execute(); } @@ -228,7 +237,8 @@ abstract class TestBase { * @see Drupal\simpletest\TestBase::insertAssert() */ public static function deleteAssert($message_id) { - return (bool) db_delete('simpletest') + return (bool) TestBase::getOriginalDatabaseConnection() + ->delete('simpletest') ->condition('message_id', $message_id) ->execute(); } @@ -486,12 +496,14 @@ abstract class TestBase { set_error_handler(array($this, 'errorHandler')); $class = get_class($this); + // Iterate through all the methods in this class, unless a specific list of // methods to run was passed. $class_methods = get_class_methods($class); if ($methods) { $class_methods = array_intersect($class_methods, $methods); } + $missing_requirements = $this->checkRequirements(); if (!empty($missing_requirements)) { $missing_requirements_object = new ReflectionObject($this); @@ -503,36 +515,51 @@ abstract class TestBase { } } else { + // Insert a fail record for the test class. + // Will be deleted after successful completion without fatal errors. + $class_info = new ReflectionClass($class); + $caller = array( + 'file' => $class_info->getFileName(), + 'line' => $class_info->getStartLine(), + 'class' => $class, + ); + $class_completion_check_id = TestBase::insertAssert($this->testId, $class, FALSE, 'Test case ended unexpectedly due to a fatal error.', 'Completion check', $caller); + + // Setup test environment. + $this->setUpBeforeClass(); + + // Run tests. foreach ($class_methods as $method) { - // If the current method starts with "test", run it - it's a test. - if (strtolower(substr($method, 0, 4)) == 'test') { - // Insert a fail record. This will be deleted on completion to ensure - // that testing completed. + // Only run "test" methods. + if (stripos($method, 'test') === 0) { + // Insert a fail record for the test method. + // Will be deleted after successful completion without fatal errors. $method_info = new ReflectionMethod($class, $method); $caller = array( 'file' => $method_info->getFileName(), 'line' => $method_info->getStartLine(), 'function' => $class . '->' . $method . '()', ); - $completion_check_id = TestBase::insertAssert($this->testId, $class, FALSE, t('The test did not complete due to a fatal error.'), 'Completion check', $caller); - $this->setUp(); - if ($this->setup) { - try { - $this->$method(); - // Finish up. - } - catch (Exception $e) { - $this->exceptionHandler($e); - } + $test_completion_check_id = TestBase::insertAssert($this->testId, $class, FALSE, 'Test method ended unexpectedly due to a fatal error.', 'Completion check', $caller); + + try { + $this->setUp(); + $this->$method(); $this->tearDown(); } - else { - $this->fail(t("The test cannot be executed because it has not been set up properly.")); + catch (Exception $e) { + $this->exceptionHandler($e); } - // Remove the completion check record. - TestBase::deleteAssert($completion_check_id); + + // Remove the test method completion check record. + TestBase::deleteAssert($test_completion_check_id); } } + // Remove the test class completion check record. + TestBase::deleteAssert($class_completion_check_id); + + // Tear down test environment. + $this->tearDownAfterClass(); } // Clear out the error messages and restore error handler. drupal_get_messages(); @@ -540,6 +567,38 @@ abstract class TestBase { } /** + * Sets up test environment; called before the first test of this test class is run. + * + * @see PHPUnit_Framework_TestCase::setUpBeforeClass() + */ + protected function setUpBeforeClass() { + } + + /** + * Sets up fixture; called before each test method. + * + * @see PHPUnit_Framework_TestCase::setUpBeforeClass() + */ + protected function setUp() { + } + + /** + * Tears down fixture; called after each test method. + * + * @see PHPUnit_Framework_TestCase::tearDown() + */ + protected function tearDown() { + } + + /** + * Tears down test environment; called after the last test of this test class has run. + * + * @see PHPUnit_Framework_TestCase::tearDownAfterClass() + */ + protected function tearDownAfterClass() { + } + + /** * Handle errors during test runs. * * Because this is registered in set_error_handler(), it has to be public. diff --git a/core/modules/simpletest/lib/Drupal/simpletest/UnitTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/UnitTestBase.php index 5b5850b..ab6c14d 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/UnitTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/UnitTestBase.php @@ -30,12 +30,12 @@ abstract class UnitTestBase extends TestBase { /** * Sets up unit test environment. * - * Unlike Drupal\simpletest\WebTestBase::setUp(), UnitTestBase::setUp() does not + * Unlike Drupal\simpletest\WebTestBase::setUpBeforeClass(), UnitTestBase::setUpBeforeClass() does not * install modules because tests are performed without accessing the database. - * Any required files must be explicitly included by the child class setUp() + * Any required files must be explicitly included by the child class setUpBeforeClass() * method. */ - protected function setUp() { + protected function setUpBeforeClass() { global $conf; // Store necessary current values before switching to the test environment. @@ -76,7 +76,7 @@ abstract class UnitTestBase extends TestBase { $this->setup = TRUE; } - protected function tearDown() { + protected function tearDownAfterClass() { global $conf; // Get back to the original connection. diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index db0f09f..d460941 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -546,7 +546,7 @@ abstract class WebTestBase extends TestBase { * * @see Drupal\simpletest\WebTestBase::curlInitialize() * @see drupal_valid_test_ua() - * @see Drupal\simpletest\WebTestBase::setUp() + * @see Drupal\simpletest\WebTestBase::setUpBeforeClass() */ protected function prepareDatabasePrefix() { $this->databasePrefix = 'simpletest' . mt_rand(1000, 1000000); @@ -563,7 +563,7 @@ abstract class WebTestBase extends TestBase { /** * Changes the database connection to the prefixed one. * - * @see Drupal\simpletest\WebTestBase::setUp() + * @see Drupal\simpletest\WebTestBase::setUpBeforeClass() */ protected function changeDatabasePrefix() { if (empty($this->databasePrefix)) { @@ -586,13 +586,13 @@ abstract class WebTestBase extends TestBase { * * Backups various current environment variables and resets them, so they do * not interfere with the Drupal site installation in which tests are executed - * and can be restored in tearDown(). + * and can be restored in tearDownAfterClass(). * * Also sets up new resources for the testing environment, such as the public * filesystem and configuration directories. * - * @see Drupal\simpletest\WebTestBase::setUp() - * @see Drupal\simpletest\WebTestBase::tearDown() + * @see Drupal\simpletest\WebTestBase::setUpBeforeClass() + * @see Drupal\simpletest\WebTestBase::tearDownAfterClass() */ protected function prepareEnvironment() { global $user, $language_interface, $conf; @@ -666,7 +666,7 @@ abstract class WebTestBase extends TestBase { * @see Drupal\simpletest\WebTestBase::changeDatabasePrefix() * @see Drupal\simpletest\WebTestBase::prepareEnvironment() */ - protected function setUp() { + protected function setUpBeforeClass() { global $user, $language_interface, $conf; // Create the database prefix for this test. @@ -769,7 +769,7 @@ abstract class WebTestBase extends TestBase { /** * Preload the registry from the testing site. * - * This method is called by Drupal\simpletest\WebTestBase::setUp(), and preloads + * This method is called by Drupal\simpletest\WebTestBase::setUpBeforeClass(), and preloads * the registry from the testing site to cut down on the time it takes to * set up a clean environment for the current test run. */ @@ -805,7 +805,7 @@ abstract class WebTestBase extends TestBase { /** * Reset all data structures after having enabled new modules. * - * This method is called by Drupal\simpletest\WebTestBase::setUp() after enabling + * This method is called by Drupal\simpletest\WebTestBase::setUpBeforeClass() after enabling * the requested modules. It must be called again when additional modules * are enabled later. */ @@ -837,10 +837,10 @@ abstract class WebTestBase extends TestBase { } /** - * Delete created files and temporary files directory, delete the tables created by setUp(), + * Delete created files and temporary files directory, delete the tables created by setUpBeforeClass(), * and reset the database prefix. */ - protected function tearDown() { + protected function tearDownAfterClass() { global $user, $language_interface; // In case a fatal error occurred that was not in the test process read the diff --git a/core/modules/simpletest/simpletest.test b/core/modules/simpletest/simpletest.test index cc4e026..46460c9 100644 --- a/core/modules/simpletest/simpletest.test +++ b/core/modules/simpletest/simpletest.test @@ -28,16 +28,21 @@ class SimpleTestFunctionalTest extends WebTestBase { ); } - function setUp() { + function setUpBeforeClass() { if (!$this->inCURL()) { - parent::setUp('simpletest'); + parent::setUpBeforeClass('simpletest'); // Create and login user - $admin_user = $this->drupalCreateUser(array('administer unit tests')); - $this->drupalLogin($admin_user); + $this->admin_user = $this->drupalCreateUser(array('administer unit tests')); } else { - parent::setUp('non_existent_module'); + parent::setUpBeforeClass('non_existent_module'); + } + } + + function setUp() { + if (!$this->inCURL()) { + $this->drupalLogin($this->admin_user); } } @@ -117,6 +122,8 @@ class SimpleTestFunctionalTest extends WebTestBase { $this->assertResponse(403, t('Requesting http.php with a normal User-Agent fails.')); $this->drupalGet($https_path); $this->assertResponse(403, t('Requesting https.php with a normal User-Agent fails.')); + + $this->additionalCurlOptions = array(); } } @@ -191,7 +198,7 @@ class SimpleTestFunctionalTest extends WebTestBase { * Confirm that the stub test produced the desired results. */ function confirmStubTestResults() { - $this->assertAssertion(t('Enabled modules: %modules', array('%modules' => 'non_existent_module')), 'Other', 'Fail', 'simpletest.test', 'SimpleTestFunctionalTest->setUp()'); + $this->assertAssertion(t('Enabled modules: %modules', array('%modules' => 'non_existent_module')), 'Other', 'Fail', 'simpletest.test', 'SimpleTestFunctionalTest->setUpBeforeClass()'); $this->assertAssertion($this->pass, 'Other', 'Pass', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()'); $this->assertAssertion($this->fail, 'Other', 'Fail', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()'); @@ -212,7 +219,7 @@ class SimpleTestFunctionalTest extends WebTestBase { $this->assertAssertion("Debug: 'Foo'", 'Debug', 'Fail', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()'); - $this->assertEqual('6 passes, 5 fails, 2 exceptions, and 1 debug message', $this->childTestResults['summary'], 'Stub test summary is correct'); + $this->assertEqual('6 passes, 3 fails, 2 exceptions, and 1 debug message', $this->childTestResults['summary']); $this->test_ids[] = $test_id = $this->getTestIdFromResults(); $this->assertTrue($test_id, t('Found test ID in results.')); @@ -335,8 +342,8 @@ class SimpleTestBrowserTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); variable_set('user_register', USER_REGISTER_VISITORS); } @@ -473,8 +480,8 @@ class SimpleTestFolderTestCase extends WebTestBase { ); } - function setUp() { - return parent::setUp('image'); + function setUpBeforeClass() { + return parent::setUpBeforeClass('image'); } function testFolderSetup() { @@ -505,10 +512,10 @@ class SimpleTestMissingDependentModuleUnitTest extends UnitTestBase { } /** - * Tests a test case that does not run parent::setUp() in its setUp() method. + * Tests a test case that does not run parent::setUpBeforeClass() in its setUpBeforeClass() method. * - * If a test case does not call parent::setUp(), running - * Drupal\simpletest\WebTestBase::tearDown() would destroy the main site's + * If a test case does not call parent::setUpBeforeClass(), running + * Drupal\simpletest\WebTestBase::tearDownAfterClass() would destroy the main site's * database tables. Therefore, we ensure that tests which are not set up * properly are skipped. * @@ -518,34 +525,34 @@ class SimpleTestBrokenSetUp extends WebTestBase { public static function getInfo() { return array( 'name' => 'Broken SimpleTest method', - 'description' => 'Tests a test case that does not call parent::setUp().', + 'description' => 'Tests a test case that does not call parent::setUpBeforeClass().', 'group' => 'SimpleTest' ); } - function setUp() { + function setUpBeforeClass() { // If the test is being run from the main site, set up normally. if (!drupal_valid_test_ua()) { - parent::setUp('simpletest'); + parent::setUpBeforeClass('simpletest'); // Create and log in user. $admin_user = $this->drupalCreateUser(array('administer unit tests')); $this->drupalLogin($admin_user); } // If the test is being run from within simpletest, set up the broken test. else { - $this->pass(t('The test setUp() method has been run.')); - // Don't call parent::setUp(). This should trigger an error message. + $this->pass(t('The test setUpBeforeClass() method has been run.')); + // Don't call parent::setUpBeforeClass(). This should trigger an error message. } } - function tearDown() { + function tearDownAfterClass() { // If the test is being run from the main site, tear down normally. if (!drupal_valid_test_ua()) { - parent::tearDown(); + parent::tearDownAfterClass(); } else { // If the test is being run from within simpletest, output a message. - $this->pass(t('The tearDown() method has run.')); + $this->pass(t('The tearDownAfterClass() method has run.')); } } @@ -559,11 +566,11 @@ class SimpleTestBrokenSetUp extends WebTestBase { $edit['SimpleTestBrokenSetUp'] = TRUE; $this->drupalPost('admin/config/development/testing', $edit, t('Run tests')); - // Verify that the broken test and its tearDown() method are skipped. - $this->assertRaw(t('The test setUp() method has been run.')); + // Verify that the broken test and its tearDownAfterClass() method are skipped. + $this->assertRaw(t('The test setUpBeforeClass() method has been run.')); $this->assertRaw(t('The test cannot be executed because it has not been set up properly.')); $this->assertNoRaw(t('The test method has run.')); - $this->assertNoRaw(t('The tearDown() method has run.')); + $this->assertNoRaw(t('The tearDownAfterClass() method has run.')); } // If the test is being run from within simpletest, output a message. else { @@ -584,8 +591,8 @@ class SimpleTestMissingCheckedRequirements extends WebTestBase { ); } - function setUp() { - parent::setUp('simpletest'); + function setUpBeforeClass() { + parent::setUpBeforeClass('simpletest'); $admin_user = $this->drupalCreateUser(array('administer unit tests')); $this->drupalLogin($admin_user); } @@ -647,8 +654,8 @@ class SimpleTestInstallationProfileModuleTestsTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('simpletest')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('simpletest')); $this->admin_user = $this->drupalCreateUser(array('administer unit tests')); $this->drupalLogin($this->admin_user); @@ -693,8 +700,8 @@ class SimpleTestOtherInstallationProfileModuleTestsTestCase extends WebTestBase ); } - function setUp() { - parent::setUp(array('simpletest')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('simpletest')); $this->admin_user = $this->drupalCreateUser(array('administer unit tests')); $this->drupalLogin($this->admin_user); diff --git a/core/modules/statistics/statistics.test b/core/modules/statistics/statistics.test index bb28b01..9135175 100644 --- a/core/modules/statistics/statistics.test +++ b/core/modules/statistics/statistics.test @@ -12,8 +12,8 @@ use Drupal\simpletest\WebTestBase; */ class StatisticsTestCase extends WebTestBase { - function setUp() { - parent::setUp(array('node', 'block', 'statistics')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('node', 'block', 'statistics')); // Create Basic page node type. if ($this->profile != 'standard') { @@ -67,8 +67,8 @@ class StatisticsLoggingTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('statistics', 'block')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('statistics', 'block')); // Create Basic page node type. if ($this->profile != 'standard') { @@ -347,8 +347,8 @@ class StatisticsAdminTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('node', 'statistics')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('node', 'statistics')); // Create Basic page node type. if ($this->profile != 'standard') { diff --git a/core/modules/syslog/syslog.test b/core/modules/syslog/syslog.test index 49da077..9ca1a7b 100644 --- a/core/modules/syslog/syslog.test +++ b/core/modules/syslog/syslog.test @@ -19,8 +19,8 @@ class SyslogTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('syslog'); + function setUpBeforeClass() { + parent::setUpBeforeClass('syslog'); } /** diff --git a/core/modules/system/system.test b/core/modules/system/system.test index 40f590e..3d5e553 100644 --- a/core/modules/system/system.test +++ b/core/modules/system/system.test @@ -16,8 +16,8 @@ use Drupal\simpletest\UnitTestBase; class ModuleTestCase extends WebTestBase { protected $admin_user; - function setUp() { - parent::setUp('system_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('system_test'); $this->admin_user = $this->drupalCreateUser(array('access administration pages', 'administer modules')); $this->drupalLogin($this->admin_user); @@ -628,8 +628,8 @@ class ModuleVersionTestCase extends ModuleTestCase { ); } - function setUp() { - parent::setUp('module_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('module_test'); } /** @@ -726,10 +726,10 @@ class IPAddressBlockingTestCase extends WebTestBase { } /** - * Implement setUp(). + * Implement setUpBeforeClass(). */ - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); // Create user. $this->blocking_user = $this->drupalCreateUser(array('block IP addresses')); @@ -799,8 +799,8 @@ class CronRunTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('common_test', 'common_test_cron_helper')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('common_test', 'common_test_cron_helper')); } /** @@ -956,8 +956,8 @@ class DefaultMobileMetaTagsTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); $this->default_metatags = array( 'MobileOptimized' => '', 'HandheldFriendly' => '', @@ -1002,8 +1002,8 @@ class AccessDeniedTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('block')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('block')); // Create an administrative user. $this->admin_user = $this->drupalCreateUser(array('access administration pages', 'administer site configuration', 'administer blocks')); @@ -1079,8 +1079,8 @@ class PageNotFoundTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); // Create an administrative user. $this->admin_user = $this->drupalCreateUser(array('administer site configuration')); @@ -1119,8 +1119,8 @@ class SiteMaintenanceTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('node')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('node')); // Configure 'node' as front page. variable_set('site_frontpage', 'node'); @@ -1221,8 +1221,8 @@ class DateTimeFunctionalTest extends WebTestBase { ); } - function setUp() { - parent::setUp(array('locale')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('locale')); // Create admin user and log in admin user. $this->admin_user = $this->drupalCreateUser(array('administer site configuration')); @@ -1421,10 +1421,10 @@ class PageTitleFiltering extends WebTestBase { } /** - * Implement setUp(). + * Implement setUpBeforeClass(). */ - function setUp() { - parent::setUp(array('node')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('node')); $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); @@ -1439,8 +1439,6 @@ class PageTitleFiltering extends WebTestBase { function tearDown() { // Restore the page title. drupal_set_title($this->saved_title, PASS_THROUGH); - - parent::tearDown(); } /** @@ -1524,8 +1522,8 @@ class FrontPageTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('node', 'system_test')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('node', 'system_test')); // Create admin user, log in admin user, and create one node. $this->admin_user = $this->drupalCreateUser(array('access content', 'administer site configuration')); @@ -1577,8 +1575,8 @@ class SystemBlockTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('block'); + function setUpBeforeClass() { + parent::setUpBeforeClass('block'); // Create and login user $admin_user = $this->drupalCreateUser(array('administer blocks', 'access administration pages')); @@ -1647,8 +1645,8 @@ class SystemMainContentFallback extends WebTestBase { ); } - function setUp() { - parent::setUp(array('block', 'system_test')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('block', 'system_test')); // Create and login admin user. $this->admin_user = $this->drupalCreateUser(array( @@ -1722,16 +1720,19 @@ class SystemThemeFunctionalTest extends WebTestBase { ); } - function setUp() { - parent::setUp(array('node', 'block')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('node', 'block')); $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); $this->admin_user = $this->drupalCreateUser(array('access administration pages', 'view the administration theme', 'administer themes', 'bypass node access', 'administer blocks')); - $this->drupalLogin($this->admin_user); $this->node = $this->drupalCreateNode(); } + function setUp() { + $this->drupalLogin($this->admin_user); + } + /** * Test the theme settings form. */ @@ -1911,6 +1912,8 @@ class SystemThemeFunctionalTest extends WebTestBase { $this->drupalGet('node/add'); $this->assertRaw('core/themes/bartik', t('Site default theme used on the add content page.')); + + variable_del('theme_default'); } /** @@ -2246,8 +2249,8 @@ class UpdateScriptFunctionalTest extends WebTestBase { ); } - function setUp() { - parent::setUp(array('update_script_test', 'dblog')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('update_script_test', 'dblog')); $this->update_url = $GLOBALS['base_url'] . '/core/update.php'; $this->update_user = $this->drupalCreateUser(array('administer software updates')); } @@ -2333,6 +2336,8 @@ class UpdateScriptFunctionalTest extends WebTestBase { $this->assertText('This is a requirements error provided by the update_script_test module.'); $this->clickLink('try again'); $this->assertText('This is a requirements error provided by the update_script_test module.'); + + variable_del('update_script_test_requirement_type'); } /** @@ -2499,8 +2504,8 @@ class ShutdownFunctionsTest extends WebTestBase { ); } - function setUp() { - parent::setUp('system_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('system_test'); } /** @@ -2531,9 +2536,9 @@ class SystemAdminTestCase extends WebTestBase { ); } - function setUp() { + function setUpBeforeClass() { // testAdminPages() requires Locale module. - parent::setUp(array('locale')); + parent::setUpBeforeClass(array('locale')); // Create an administrator with all permissions, as well as a regular user // who can only access administration pages and perform some Locale module @@ -2831,8 +2836,8 @@ class SystemAuthorizeCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('system_test')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('system_test')); variable_set('allow_authorize_operations', TRUE); @@ -2884,8 +2889,8 @@ class SystemIndexPhpTest extends WebTestBase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); } /** diff --git a/core/modules/system/tests/actions.test b/core/modules/system/tests/actions.test index 469b16e..2f85284 100644 --- a/core/modules/system/tests/actions.test +++ b/core/modules/system/tests/actions.test @@ -79,8 +79,8 @@ class ActionLoopTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('dblog', 'actions_loop_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('dblog', 'actions_loop_test'); } /** diff --git a/core/modules/system/tests/ajax.test b/core/modules/system/tests/ajax.test index 69b178b..9ec0d3c 100644 --- a/core/modules/system/tests/ajax.test +++ b/core/modules/system/tests/ajax.test @@ -4,12 +4,12 @@ use Drupal\simpletest\WebTestBase; class AJAXTestCase extends WebTestBase { - function setUp() { + function setUpBeforeClass() { $modules = func_get_args(); if (isset($modules[0]) && is_array($modules[0])) { $modules = $modules[0]; } - parent::setUp(array_unique(array_merge(array('ajax_test', 'ajax_forms_test'), $modules))); + parent::setUpBeforeClass(array_unique(array_merge(array('ajax_test', 'ajax_forms_test'), $modules))); } /** @@ -384,8 +384,8 @@ class AJAXFormValuesTestCase extends AJAXTestCase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); $this->web_user = $this->drupalCreateUser(array('access content')); $this->drupalLogin($this->web_user); @@ -437,8 +437,8 @@ class AJAXMultiFormTestCase extends AJAXTestCase { ); } - function setUp() { - parent::setUp(array('form_test')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('form_test')); // Create a multi-valued field for 'page' nodes to use for Ajax testing. $field_name = 'field_ajax_test'; diff --git a/core/modules/system/tests/batch.test b/core/modules/system/tests/batch.test index e39bcf5..5209e73 100644 --- a/core/modules/system/tests/batch.test +++ b/core/modules/system/tests/batch.test @@ -21,8 +21,8 @@ class BatchProcessingTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('batch_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('batch_test'); } /** @@ -290,8 +290,8 @@ class BatchPageTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('batch_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('batch_test'); } /** @@ -331,7 +331,7 @@ class BatchPercentagesUnitTestCase extends UnitTestBase { ); } - function setUp() { + function setUpBeforeClass() { // Set up an array of test cases, where the expected values are the keys, // and the values are arrays with the keys 'total' and 'current', // corresponding with the function parameters of _batch_api_percentage(). @@ -384,7 +384,7 @@ class BatchPercentagesUnitTestCase extends UnitTestBase { '99.8' => array('total' => 1, 'current' => 500/501), ); require_once DRUPAL_ROOT . '/core/includes/batch.inc'; - parent::setUp(); + parent::setUpBeforeClass(); } /** diff --git a/core/modules/system/tests/bootstrap.test b/core/modules/system/tests/bootstrap.test index 098e12e..e947762 100644 --- a/core/modules/system/tests/bootstrap.test +++ b/core/modules/system/tests/bootstrap.test @@ -13,7 +13,7 @@ class BootstrapIPAddressTestCase extends WebTestBase { ); } - function setUp() { + function setUpBeforeClass() { $this->oldserver = $_SERVER; $this->remote_ip = '127.0.0.1'; @@ -29,13 +29,12 @@ class BootstrapIPAddressTestCase extends WebTestBase { unset($_SERVER['HTTP_X_FORWARDED_FOR']); unset($_SERVER['HTTP_X_CLUSTER_CLIENT_IP']); - parent::setUp(); + parent::setUpBeforeClass(); } function tearDown() { $_SERVER = $this->oldserver; drupal_static_reset('ip_address'); - parent::tearDown(); } /** @@ -111,21 +110,21 @@ class BootstrapPageCacheTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('node', 'system_test')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('node', 'system_test')); variable_set('site_name', 'Drupal'); variable_set('site_frontpage', 'node'); } + function setUp() { + config('system.performance')->set('cache', 1)->save(); + } + /** * Test support for requests containing If-Modified-Since and If-None-Match headers. */ function testConditionalRequests() { - $config = config('system.performance'); - $config->set('cache', 1); - $config->save(); - // Fill the cache. $this->drupalGet(''); @@ -156,16 +155,13 @@ class BootstrapPageCacheTestCase extends WebTestBase { $this->drupalGet('', array(), array('If-Modified-Since: ' . $last_modified, 'If-None-Match: ' . $etag)); $this->assertResponse(200, t('Conditional request returned 200 OK for authenticated user.')); $this->assertFalse($this->drupalGetHeader('X-Drupal-Cache'), t('Absense of Page was not cached.')); + $this->drupalLogout(); } /** * Test cache headers. */ function testPageCache() { - $config = config('system.performance'); - $config->set('cache', 1); - $config->save(); - // Fill the cache. $this->drupalGet('system-test/set-header', array('query' => array('name' => 'Foo', 'value' => 'bar'))); $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', t('Page was not cached.')); @@ -198,6 +194,7 @@ class BootstrapPageCacheTestCase extends WebTestBase { $this->assertEqual($this->drupalGetHeader('Expires'), 'Sun, 19 Nov 1978 05:00:00 GMT', t('Expires header was sent.')); $this->assertEqual($this->drupalGetHeader('Foo'), 'bar', t('Custom header was sent.')); + $this->drupalLogout(); } /** @@ -208,10 +205,6 @@ class BootstrapPageCacheTestCase extends WebTestBase { * mod_deflate Apache module. */ function testPageCompression() { - $config = config('system.performance'); - $config->set('cache', 1); - $config->save(); - // Fill the cache and verify that output is compressed. $this->drupalGet('', array(), array('Accept-Encoding: gzip,deflate')); $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', t('Page was not cached.')); @@ -236,8 +229,8 @@ class BootstrapPageCacheTestCase extends WebTestBase { class BootstrapVariableTestCase extends WebTestBase { - function setUp() { - parent::setUp('system_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('system_test'); } public static function getInfo() { @@ -294,8 +287,8 @@ class HookBootExitTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('system_test', 'dblog'); + function setUpBeforeClass() { + parent::setUpBeforeClass('system_test', 'dblog'); } /** diff --git a/core/modules/system/tests/cache.test b/core/modules/system/tests/cache.test index 8a5d9ff..476435b 100644 --- a/core/modules/system/tests/cache.test +++ b/core/modules/system/tests/cache.test @@ -189,9 +189,9 @@ class CacheGetMultipleUnitTest extends CacheTestCase { ); } - function setUp() { + function setUpBeforeClass() { $this->default_bin = 'page'; - parent::setUp(); + parent::setUpBeforeClass(); } /** @@ -236,11 +236,11 @@ class CacheClearCase extends CacheTestCase { ); } - function setUp() { + function setUpBeforeClass() { $this->default_bin = 'page'; $this->default_value = $this->randomName(10); - parent::setUp(); + parent::setUpBeforeClass(); } /** @@ -434,11 +434,11 @@ class CacheIsEmptyCase extends CacheTestCase { ); } - function setUp() { + function setUpBeforeClass() { $this->default_bin = 'page'; $this->default_value = $this->randomName(10); - parent::setUp(); + parent::setUpBeforeClass(); } /** @@ -474,8 +474,8 @@ class CacheInstallTestCase extends CacheTestCase { ); } - function setUp() { - parent::setUp(array('cache_test')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('cache_test')); } /** diff --git a/core/modules/system/tests/common.test b/core/modules/system/tests/common.test index b50daad..4b0182c 100644 --- a/core/modules/system/tests/common.test +++ b/core/modules/system/tests/common.test @@ -20,8 +20,8 @@ class CommonDrupalAlterTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('block', 'common_test')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('block', 'common_test')); } function testDrupalAlter() { @@ -367,7 +367,7 @@ class CommonSizeUnitTestCase extends UnitTestBase { ); } - function setUp() { + function setUpBeforeClass() { $kb = DRUPAL_KILOBYTE; $this->exact_test_cases = array( '1 byte' => 1, @@ -387,7 +387,7 @@ class CommonSizeUnitTestCase extends UnitTestBase { round(67234178751368124 / ($this->exact_test_cases['1 PB']), 2) . ' PB' => 67234178751368124, // petabytes round(235346823821125814962843827 / ($this->exact_test_cases['1 YB']), 2) . ' YB' => 235346823821125814962843827, // yottabytes ); - parent::setUp(); + parent::setUpBeforeClass(); } /** @@ -521,9 +521,11 @@ class CommonCascadingStylesheetsTestCase extends WebTestBase { ); } + function setUpBeforeClass() { + parent::setUpBeforeClass(array('language', 'common_test')); + } + function setUp() { - parent::setUp(array('language', 'common_test')); - // Reset drupal_add_css() before each test. drupal_static_reset('drupal_add_css'); } @@ -867,8 +869,8 @@ class CommonDrupalHTTPRequestTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('system_test', 'locale'); + function setUpBeforeClass() { + parent::setUpBeforeClass('system_test', 'locale'); } function testDrupalHTTPRequest() { @@ -1044,8 +1046,8 @@ class CommonDrupalGotoTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('common_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('common_test'); } /** @@ -1118,27 +1120,24 @@ class CommonJavaScriptTestCase extends WebTestBase { ); } - function setUp() { + function setUpBeforeClass() { // Enable Locale and SimpleTest in the test environment. - parent::setUp('locale', 'simpletest', 'common_test'); + parent::setUpBeforeClass('locale', 'simpletest', 'common_test'); - // Disable preprocessing - $config = config('system.performance'); - $this->preprocess_js = $config->get('preprocess_js'); - $config->set('preprocess_js', 0); - $config->save(); + $this->preprocess_js = config('system.performance')->get('preprocess_js'); + } - // Reset drupal_add_js() and drupal_add_library() statics before each test. + function setUp() { + // Disable preprocessing. + config('system.performance')->set('preprocess_js', 0)->save(); + // Reset statics. drupal_static_reset('drupal_add_js'); drupal_static_reset('drupal_add_library'); } - function tearDown() { + function tearDownAfterClass() { // Restore configured value for JavaScript preprocessing. - $config = config('system.performance'); - $config->set('preprocess_js', $this->preprocess_js); - $config->save(); - parent::tearDown(); + config('system.performance')->set('preprocess_js', $this->preprocess_js)->save(); } /** @@ -1358,7 +1357,8 @@ class CommonJavaScriptTestCase extends WebTestBase { function testAggregationOrder() { // Enable JavaScript aggregation. config('system.performance')->set('preprocess_js', 1)->save(); - drupal_static_reset('drupal_add_js'); + // Empty out the JS cache variable. + variable_set('drupal_js_cache_files', array()); // Add two JavaScript files to the current request and build the cache. drupal_add_js('core/misc/ajax.js'); @@ -1570,8 +1570,8 @@ class CommonDrupalRenderTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('common_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('common_test'); } /** @@ -2064,8 +2064,8 @@ class CommonDrupalWriteRecordTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('database_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('database_test'); } /** @@ -2211,8 +2211,8 @@ class CommonSimpleTestErrorCollectorTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('system_test', 'error_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('system_test', 'error_test'); } /** @@ -2375,8 +2375,8 @@ class CommonFormatDateTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('locale'); + function setUpBeforeClass() { + parent::setUpBeforeClass('locale'); variable_set('configurable_timezones', 1); variable_set('date_format_long', 'l, j. F Y - G:i'); variable_set('date_format_medium', 'j. F Y - G:i'); @@ -2549,8 +2549,8 @@ class CommonDrupalArrayUnitTest extends UnitTestBase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); // Create a form structure with a nested element. $this->form['fieldset']['element'] = array( @@ -2605,6 +2605,19 @@ class CommonDrupalArrayUnitTest extends UnitTestBase { } /** + * Tests existence of array key. + */ + function testKeyExists() { + // Verify that existing key is found. + $this->assertIdentical(drupal_array_nested_key_exists($this->form, $this->parents), TRUE, 'Nested key found.'); + + // Verify that non-existing keys are not found. + $parents = $this->parents; + $parents[] = 'foo'; + $this->assertIdentical(drupal_array_nested_key_exists($this->form, $parents), FALSE, 'Non-existing nested key not found.'); + } + + /** * Tests unsetting nested array values. */ function testUnset() { @@ -2623,19 +2636,6 @@ class CommonDrupalArrayUnitTest extends UnitTestBase { $this->assertFalse(isset($this->form['fieldset']['element']), 'Removed nested element not found.'); $this->assertIdentical($key_existed, TRUE, 'Existing key was found.'); } - - /** - * Tests existence of array key. - */ - function testKeyExists() { - // Verify that existing key is found. - $this->assertIdentical(drupal_array_nested_key_exists($this->form, $this->parents), TRUE, 'Nested key found.'); - - // Verify that non-existing keys are not found. - $parents = $this->parents; - $parents[] = 'foo'; - $this->assertIdentical(drupal_array_nested_key_exists($this->form, $parents), FALSE, 'Non-existing nested key not found.'); - } } /** diff --git a/core/modules/system/tests/database.test b/core/modules/system/tests/database.test index 889a30c..15b361a 100644 --- a/core/modules/system/tests/database.test +++ b/core/modules/system/tests/database.test @@ -26,13 +26,13 @@ class FakeRecord { } * here. */ class DatabaseTestCase extends WebTestBase { - function setUp() { + function setUpBeforeClass() { $modules = func_get_args(); if (isset($modules[0]) && is_array($modules[0])) { $modules = $modules[0]; } $modules[] = 'database_test'; - parent::setUp($modules); + parent::setUpBeforeClass($modules); $schema['test'] = drupal_get_schema('test'); $schema['test_people'] = drupal_get_schema('test_people'); @@ -2227,8 +2227,8 @@ class DatabaseSelectComplexTestCase2 extends DatabaseTestCase { ); } - function setUp() { - parent::setUp(array('node_access_test')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('node_access_test')); } /** @@ -2754,8 +2754,8 @@ class DatabaseRegressionTestCase extends DatabaseTestCase { ); } - function setUp() { - parent::setUp(array('node')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('node')); } /** @@ -2968,8 +2968,8 @@ class DatabaseRangeQueryTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('database_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('database_test'); } /** @@ -2999,8 +2999,8 @@ class DatabaseTemporaryQueryTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('database_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('database_test'); } /** diff --git a/core/modules/system/tests/error.test b/core/modules/system/tests/error.test index a088902..dbf988f 100644 --- a/core/modules/system/tests/error.test +++ b/core/modules/system/tests/error.test @@ -15,8 +15,8 @@ class DrupalErrorHandlerUnitTest extends WebTestBase { ); } - function setUp() { - parent::setUp('error_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('error_test'); } /** diff --git a/core/modules/system/tests/file.test b/core/modules/system/tests/file.test index f679f98..f6721c0 100644 --- a/core/modules/system/tests/file.test +++ b/core/modules/system/tests/file.test @@ -50,10 +50,10 @@ function file_test_file_scan_callback_reset() { */ class FileTestCase extends WebTestBase { - function setUp() { + function setUpBeforeClass() { $modules = func_get_args(); $modules = (isset($modules[0]) && is_array($modules[0]) ? $modules[0] : $modules); - parent::setUp($modules); + parent::setUpBeforeClass($modules); // Make sure that custom stream wrappers are registered. // @todo This has the potential to be a major bug deeply buried in File API; @@ -251,9 +251,9 @@ class FileTestCase extends WebTestBase { * hooks. */ class FileHookTestCase extends FileTestCase { - function setUp() { + function setUpBeforeClass() { // Install file_test module - parent::setUp('file_test'); + parent::setUpBeforeClass('file_test'); // Clear out any hook calls. file_test_reset(); } @@ -330,8 +330,8 @@ class FileSpaceUsedTest extends FileTestCase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); // Create records for a couple of users with different sizes. $file = array('uid' => 2, 'uri' => 'public://example1.txt', 'filesize' => 50, 'status' => FILE_STATUS_PERMANENT); @@ -385,8 +385,8 @@ class FileValidatorTest extends WebTestBase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); $this->image = new stdClass(); $this->image->uri = 'core/misc/druplicon.png'; @@ -573,8 +573,8 @@ class RemoteFileUnmanagedSaveDataTest extends FileUnmanagedSaveDataTest { return $info; } - function setUp() { - parent::setUp('file_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('file_test'); variable_set('file_default_scheme', 'dummy-remote'); } } @@ -606,8 +606,8 @@ class FileSaveUploadTest extends FileHookTestCase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); $account = $this->drupalCreateUser(array('access content')); $this->drupalLogin($account); @@ -909,8 +909,8 @@ class RemoteFileSaveUploadTest extends FileSaveUploadTest { return $info; } - function setUp() { - parent::setUp('file_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('file_test'); variable_set('file_default_scheme', 'dummy-remote'); } } @@ -1048,8 +1048,8 @@ class RemoteFileDirectoryTest extends FileDirectoryTest { return $info; } - function setUp() { - parent::setUp('file_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('file_test'); variable_set('file_default_scheme', 'dummy-remote'); } } @@ -1066,8 +1066,8 @@ class FileScanDirectoryTest extends FileTestCase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); $this->path = drupal_get_path('module', 'simpletest') . '/files'; } @@ -1193,8 +1193,8 @@ class RemoteFileScanDirectoryTest extends FileScanDirectoryTest { return $info; } - function setUp() { - parent::setUp('file_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('file_test'); variable_set('file_default_scheme', 'dummy-remote'); } } @@ -1254,8 +1254,8 @@ class RemoteFileUnmanagedDeleteTest extends FileUnmanagedDeleteTest { return $info; } - function setUp() { - parent::setUp('file_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('file_test'); variable_set('file_default_scheme', 'dummy-remote'); } } @@ -1346,8 +1346,8 @@ class RemoteFileUnmanagedDeleteRecursiveTest extends FileUnmanagedDeleteRecursiv return $info; } - function setUp() { - parent::setUp('file_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('file_test'); variable_set('file_default_scheme', 'dummy-remote'); } } @@ -1434,8 +1434,8 @@ class RemoteFileUnmanagedMoveTest extends FileUnmanagedMoveTest { return $info; } - function setUp() { - parent::setUp('file_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('file_test'); variable_set('file_default_scheme', 'dummy-remote'); } } @@ -1538,8 +1538,8 @@ class RemoteFileUnmanagedCopyTest extends FileUnmanagedCopyTest { return $info; } - function setUp() { - parent::setUp('file_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('file_test'); variable_set('file_default_scheme', 'dummy-remote'); } } @@ -2375,8 +2375,8 @@ class FileDownloadTest extends FileTestCase { ); } - function setUp() { - parent::setUp('file_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('file_test'); // Clear out any hook calls. file_test_reset(); } @@ -2519,8 +2519,8 @@ class FileURLRewritingTest extends FileTestCase { ); } - function setUp() { - parent::setUp('file_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('file_test'); } /** @@ -2597,8 +2597,8 @@ class FileNameMungingTest extends FileTestCase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); $this->bad_extension = 'php'; $this->name = $this->randomName() . '.' . $this->bad_extension . '.txt'; } @@ -2648,8 +2648,8 @@ class FileNameMungingTest extends FileTestCase { * Tests for file_get_mimetype(). */ class FileMimeTypeTest extends WebTestBase { - function setUp() { - parent::setUp('file_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('file_test'); } public static function getInfo() { @@ -2745,14 +2745,17 @@ class StreamWrapperTest extends WebTestBase { ); } + function setUpBeforeClass() { + parent::setUpBeforeClass('file_test'); + } + function setUp() { - parent::setUp('file_test'); drupal_static_reset('file_get_stream_wrappers'); } - function tearDown() { - parent::tearDown(); + function tearDownAfterClass() { stream_wrapper_unregister($this->scheme); + parent::tearDownAfterClass(); } /** diff --git a/core/modules/system/tests/filetransfer.test b/core/modules/system/tests/filetransfer.test index 3f88f4b..fe1b586 100644 --- a/core/modules/system/tests/filetransfer.test +++ b/core/modules/system/tests/filetransfer.test @@ -18,8 +18,8 @@ class FileTranferTest extends WebTestBase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); $this->testConnection = TestFileTransfer::factory(DRUPAL_ROOT, array('hostname' => $this->hostname, 'username' => $this->username, 'password' => $this->password, 'port' => $this->port)); } diff --git a/core/modules/system/tests/form.test b/core/modules/system/tests/form.test index fe5f922..5514556 100644 --- a/core/modules/system/tests/form.test +++ b/core/modules/system/tests/form.test @@ -17,8 +17,8 @@ class FormsTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('form_test', 'file')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('form_test', 'file')); $filtered_html_format = array( 'format' => 'filtered_html', @@ -569,8 +569,8 @@ class FormElementTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('form_test')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('form_test')); } /** @@ -650,8 +650,8 @@ class FormAlterTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('block', 'form_test')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('block', 'form_test')); } /** @@ -684,8 +684,8 @@ class FormValidationTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('form_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('form_test'); } /** @@ -860,8 +860,8 @@ class FormsElementsLabelsTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('form_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('form_test'); } /** @@ -947,8 +947,8 @@ class FormsElementsTableSelectFunctionalTest extends WebTestBase { ); } - function setUp() { - parent::setUp('form_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('form_test'); } @@ -1173,8 +1173,8 @@ class FormsElementsVerticalTabsFunctionalTest extends WebTestBase { ); } - function setUp() { - parent::setUp('form_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('form_test'); } /** @@ -1209,8 +1209,8 @@ class FormsFormStorageTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('form_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('form_test'); $this->web_user = $this->drupalCreateUser(array('access content')); $this->drupalLogin($this->web_user); @@ -1352,8 +1352,8 @@ class FormsFormWrapperTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('form_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('form_test'); } /** @@ -1378,8 +1378,8 @@ class FormStateValuesCleanTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('form_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('form_test'); } /** @@ -1431,8 +1431,8 @@ class FormStateValuesCleanAdvancedTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('file', 'form_test')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('file', 'form_test')); } /** @@ -1473,8 +1473,8 @@ class FormsRebuildTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('form_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('form_test'); $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); @@ -1568,8 +1568,8 @@ class FormsProgrammaticTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('form_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('form_test'); } /** @@ -1657,8 +1657,8 @@ class FormsTriggeringElementTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('form_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('form_test'); } /** @@ -1754,8 +1754,8 @@ class FormsArbitraryRebuildTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('form_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('form_test'); // Auto-create a field for testing. $field = array( 'field_name' => 'test_multiple', @@ -1821,8 +1821,8 @@ class FormsFileInclusionTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('form_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('form_test'); } /** @@ -1855,8 +1855,8 @@ class FormCheckboxTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('form_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('form_test'); } function testFormCheckbox() { @@ -1937,8 +1937,8 @@ class FormEmailTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('form_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('form_test'); } /** @@ -1981,8 +1981,8 @@ class FormUrlTestCase extends WebTestBase { ); } - public function setUp() { - parent::setUp('form_test'); + public function setUpBeforeClass() { + parent::setUpBeforeClass('form_test'); } /** diff --git a/core/modules/system/tests/image.test b/core/modules/system/tests/image.test index ab9eaa4..105c16d 100644 --- a/core/modules/system/tests/image.test +++ b/core/modules/system/tests/image.test @@ -15,8 +15,8 @@ class ImageToolkitTestCase extends WebTestBase { protected $file; protected $image; - function setUp() { - parent::setUp('image_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('image_test'); // Use the image_test.module's test toolkit. $this->toolkit = 'test'; @@ -31,7 +31,9 @@ class ImageToolkitTestCase extends WebTestBase { $this->image->source = $this->file; $this->image->info = image_get_info($this->file); $this->image->toolkit = $this->toolkit; + } + function setUp() { // Clear out any hook calls. image_test_reset(); } diff --git a/core/modules/system/tests/installer.test b/core/modules/system/tests/installer.test index f076ba9..fda7e69 100644 --- a/core/modules/system/tests/installer.test +++ b/core/modules/system/tests/installer.test @@ -20,8 +20,8 @@ class InstallerLanguageTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); variable_set('locale_translate_file_directory', drupal_get_path('module', 'simpletest') . '/files/translations'); } diff --git a/core/modules/system/tests/lock.test b/core/modules/system/tests/lock.test index 65dcf80..06fe860 100644 --- a/core/modules/system/tests/lock.test +++ b/core/modules/system/tests/lock.test @@ -16,8 +16,8 @@ class LockFunctionalTest extends WebTestBase { ); } - function setUp() { - parent::setUp('system_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('system_test'); } /** diff --git a/core/modules/system/tests/mail.test b/core/modules/system/tests/mail.test index 38c6dc8..2e72beb 100644 --- a/core/modules/system/tests/mail.test +++ b/core/modules/system/tests/mail.test @@ -28,8 +28,8 @@ class MailTestCase extends WebTestBase implements MailInterface { ); } - function setUp() { - parent::setUp(array('simpletest')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('simpletest')); // Set MailTestCase (i.e. this class) as the SMTP library variable_set('mail_system', array('default-system' => 'MailTestCase')); diff --git a/core/modules/system/tests/menu.test b/core/modules/system/tests/menu.test index dbd94a1..966ecf6 100644 --- a/core/modules/system/tests/menu.test +++ b/core/modules/system/tests/menu.test @@ -9,12 +9,12 @@ use Drupal\simpletest\WebTestBase; use Drupal\simpletest\UnitTestBase; class MenuWebTestCase extends WebTestBase { - function setUp() { + function setUpBeforeClass() { $modules = func_get_args(); if (isset($modules[0]) && is_array($modules[0])) { $modules = $modules[0]; } - parent::setUp($modules); + parent::setUpBeforeClass($modules); } /** @@ -134,9 +134,9 @@ class MenuRouterTestCase extends WebTestBase { ); } - function setUp() { + function setUpBeforeClass() { // Enable dummy module that implements hook_menu. - parent::setUp(array('block', 'menu_test')); + parent::setUpBeforeClass(array('block', 'menu_test')); // Make the tests below more robust by explicitly setting the default theme // and administrative theme that they expect. @@ -238,6 +238,8 @@ class MenuRouterTestCase extends WebTestBase { $this->drupalGet('menu-test/theme-callback/use-admin-theme'); $this->assertText('Custom theme: seven. Actual theme: seven.', t('The theme callback system is correctly triggered for an administrator when the site is in maintenance mode.')); $this->assertRaw('seven/style.css', t("The administrative theme's CSS appears on the page.")); + + $this->drupalLogout(); } /** @@ -246,13 +248,13 @@ class MenuRouterTestCase extends WebTestBase { * @see hook_menu_site_status_alter(). */ function testMaintenanceModeLoginPaths() { - variable_set('maintenance_mode', TRUE); - $offline_message = t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => variable_get('site_name', 'Drupal'))); $this->drupalGet('node'); $this->assertText($offline_message); $this->drupalGet('menu_login_callback'); $this->assertText('This is menu_login_callback().', t('Maintenance mode can be bypassed through hook_menu_site_status_alter().')); + + variable_set('maintenance_mode', 0); } /** @@ -320,6 +322,8 @@ class MenuRouterTestCase extends WebTestBase { $this->drupalGet('menu-test/no-theme-callback'); $this->assertText('Custom theme: stark. Actual theme: stark.', t('The result of hook_custom_theme() is used as the theme for the current page.')); $this->assertRaw('stark/css/layout.css', t("The Stark theme's CSS appears on the page.")); + + variable_del('menu_test_hook_custom_theme_name'); } /** @@ -336,6 +340,8 @@ class MenuRouterTestCase extends WebTestBase { $this->drupalGet('menu-test/theme-callback/use-admin-theme'); $this->assertText('Custom theme: seven. Actual theme: seven.', t('The result of hook_custom_theme() does not override what was set in a theme callback.')); $this->assertRaw('seven/style.css', t("The Seven theme's CSS appears on the page.")); + + variable_del('menu_test_hook_custom_theme_name'); } /** @@ -1007,8 +1013,8 @@ class MenuTreeOutputTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); } /** @@ -1045,8 +1051,8 @@ class MenuBreadcrumbTestCase extends MenuWebTestCase { ); } - function setUp() { - parent::setUp(array('menu_test')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('menu_test')); $perms = array_keys(module_invoke_all('permission')); $this->admin_user = $this->drupalCreateUser($perms); @@ -1536,8 +1542,8 @@ class MenuTrailTestCase extends MenuWebTestCase { ); } - function setUp() { - parent::setUp(array('block', 'menu_test')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('block', 'menu_test')); $this->admin_user = $this->drupalCreateUser(array('administer site configuration', 'access administration pages')); $this->drupalLogin($this->admin_user); diff --git a/core/modules/system/tests/module.test b/core/modules/system/tests/module.test index 761992d..121cba4 100644 --- a/core/modules/system/tests/module.test +++ b/core/modules/system/tests/module.test @@ -318,8 +318,8 @@ class ModuleInstallTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('module_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('module_test'); } /** @@ -355,8 +355,8 @@ class ModuleUninstallTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('module_test', 'user'); + function setUpBeforeClass() { + parent::setUpBeforeClass('module_test', 'user'); } /** diff --git a/core/modules/system/tests/pager.test b/core/modules/system/tests/pager.test index 7d091f8..df35b44 100644 --- a/core/modules/system/tests/pager.test +++ b/core/modules/system/tests/pager.test @@ -21,8 +21,8 @@ class PagerFunctionalWebTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('dblog')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('dblog')); // Insert 300 log messages. for ($i = 0; $i < 300; $i++) { diff --git a/core/modules/system/tests/password.test b/core/modules/system/tests/password.test index 2587822..00c016d 100644 --- a/core/modules/system/tests/password.test +++ b/core/modules/system/tests/password.test @@ -19,9 +19,9 @@ class PasswordHashingTest extends WebTestBase { ); } - function setUp() { + function setUpBeforeClass() { require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'core/includes/password.inc'); - parent::setUp(); + parent::setUpBeforeClass(); } /** diff --git a/core/modules/system/tests/path.test b/core/modules/system/tests/path.test index 271cd91..bd588dc 100644 --- a/core/modules/system/tests/path.test +++ b/core/modules/system/tests/path.test @@ -23,9 +23,9 @@ class DrupalMatchPathTestCase extends WebTestBase { ); } - function setUp() { + function setUpBeforeClass() { // Set up the database and testing environment. - parent::setUp(); + parent::setUpBeforeClass(); // Set up a random site front page to test the '' placeholder. $this->front = $this->randomName(); @@ -140,8 +140,8 @@ class UrlAlterFunctionalTest extends WebTestBase { ); } - function setUp() { - parent::setUp('path', 'forum', 'url_alter_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('path', 'forum', 'url_alter_test'); } /** @@ -348,9 +348,9 @@ class PathSaveTest extends WebTestBase { ); } - function setUp() { + function setUpBeforeClass() { // Enable a helper module that implements hook_path_update(). - parent::setUp('path_test'); + parent::setUpBeforeClass('path_test'); path_test_reset(); } diff --git a/core/modules/system/tests/registry.test b/core/modules/system/tests/registry.test index 7ad8326..9aed5ab 100644 --- a/core/modules/system/tests/registry.test +++ b/core/modules/system/tests/registry.test @@ -11,12 +11,12 @@ class RegistryParseFileTestCase extends WebTestBase { ); } - function setUp() { + function setUpBeforeClass() { $chrs = hash('sha256', microtime() . mt_rand()); $this->fileName = 'registry_test_' . substr($chrs, 0, 16); $this->className = 'registry_test_class' . substr($chrs, 16, 16); $this->interfaceName = 'registry_test_interface' . substr($chrs, 32, 16); - parent::setUp(); + parent::setUpBeforeClass(); } /** @@ -58,8 +58,8 @@ class RegistryParseFilesTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); // Create files with some php to parse - one 'new', one 'existing' so // we test all the important code paths in _registry_parse_files. foreach ($this->fileTypes as $fileType) { diff --git a/core/modules/system/tests/session.test b/core/modules/system/tests/session.test index 0c9a172..033e4b5 100644 --- a/core/modules/system/tests/session.test +++ b/core/modules/system/tests/session.test @@ -16,8 +16,8 @@ class SessionTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('session_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('session_test'); } /** @@ -305,8 +305,8 @@ class SessionHttpsTestCase extends WebTestBase { ); } - public function setUp() { - parent::setUp('session_test'); + public function setUpBeforeClass() { + parent::setUpBeforeClass('session_test'); } protected function testHttpsSession() { diff --git a/core/modules/system/tests/symfony.test b/core/modules/system/tests/symfony.test index 0719c7c..082c4cb 100644 --- a/core/modules/system/tests/symfony.test +++ b/core/modules/system/tests/symfony.test @@ -19,8 +19,8 @@ class SymfonyClassLoaderTestCase extends UnitTestBase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); } /** diff --git a/core/modules/system/tests/tablesort.test b/core/modules/system/tests/tablesort.test index 1dc35fe..8f70290 100644 --- a/core/modules/system/tests/tablesort.test +++ b/core/modules/system/tests/tablesort.test @@ -27,18 +27,16 @@ class TableSortTest extends UnitTestBase { ); } - function setUp() { + function setUpBeforeClass() { // Save the original $_GET to be restored later. $this->GET = $_GET; - parent::setUp(); + parent::setUpBeforeClass(); } function tearDown() { // Revert $_GET. $_GET = $this->GET; - - parent::tearDown(); } /** diff --git a/core/modules/system/tests/theme.test b/core/modules/system/tests/theme.test index d7c6fb2..fe88ff2 100644 --- a/core/modules/system/tests/theme.test +++ b/core/modules/system/tests/theme.test @@ -20,8 +20,8 @@ class ThemeUnitTest extends WebTestBase { ); } - function setUp() { - parent::setUp('theme_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('theme_test'); theme_enable(array('test_theme')); } @@ -77,6 +77,7 @@ class ThemeUnitTest extends WebTestBase { // it to see if we are on the front page. variable_set('site_frontpage', 'node'); _current_path('node'); + drupal_static_reset('drupal_is_front_page'); $suggestions = theme_get_suggestions(array('node'), 'page'); // Set it back to not annoy the batch runner. _current_path($original_path); @@ -502,8 +503,8 @@ class ThemeHookInitUnitTest extends WebTestBase { ); } - function setUp() { - parent::setUp('theme_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('theme_test'); } /** @@ -531,8 +532,8 @@ class ThemeFastTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('theme_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('theme_test'); $this->account = $this->drupalCreateUser(array('access user profiles')); } @@ -584,8 +585,8 @@ class ThemeHtmlTplPhpAttributesTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('theme_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('theme_test'); } /** @@ -612,8 +613,8 @@ class ThemeRegistryTestCase extends WebTestBase { 'group' => 'Theme', ); } - function setUp() { - parent::setUp('theme_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('theme_test'); } /** diff --git a/core/modules/system/tests/update.test b/core/modules/system/tests/update.test index 72bc61a..f4076cc 100644 --- a/core/modules/system/tests/update.test +++ b/core/modules/system/tests/update.test @@ -19,8 +19,8 @@ class UpdateDependencyOrderingTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('update_test_1', 'update_test_2', 'update_test_3'); + function setUpBeforeClass() { + parent::setUpBeforeClass('update_test_1', 'update_test_2', 'update_test_3'); require_once DRUPAL_ROOT . '/core/includes/update.inc'; } @@ -69,10 +69,10 @@ class UpdateDependencyMissingTestCase extends WebTestBase { ); } - function setUp() { + function setUpBeforeClass() { // Only install update_test_2.module, even though its updates have a // dependency on update_test_3.module. - parent::setUp('update_test_2'); + parent::setUpBeforeClass('update_test_2'); require_once DRUPAL_ROOT . '/core/includes/update.inc'; } @@ -99,8 +99,8 @@ class UpdateDependencyHookInvocationTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('update_test_1', 'update_test_2'); + function setUpBeforeClass() { + parent::setUpBeforeClass('update_test_1', 'update_test_2'); require_once DRUPAL_ROOT . '/core/includes/update.inc'; } diff --git a/core/modules/system/tests/upgrade/upgrade.language.test b/core/modules/system/tests/upgrade/upgrade.language.test index 91e1fec..4cd6cba 100644 --- a/core/modules/system/tests/upgrade/upgrade.language.test +++ b/core/modules/system/tests/upgrade/upgrade.language.test @@ -19,13 +19,13 @@ class LanguageUpgradePathTestCase extends UpgradePathTestCase { ); } - public function setUp() { + public function setUpBeforeClass() { // Path to the database dump files. $this->databaseDumpFiles = array( drupal_get_path('module', 'system') . '/tests/upgrade/drupal-7.filled.standard_all.database.php.gz', drupal_get_path('module', 'system') . '/tests/upgrade/drupal-7.language.database.php', ); - parent::setUp(); + parent::setUpBeforeClass(); } /** diff --git a/core/modules/system/tests/upgrade/upgrade.test b/core/modules/system/tests/upgrade/upgrade.test index 2f942fa..2834b22 100644 --- a/core/modules/system/tests/upgrade/upgrade.test +++ b/core/modules/system/tests/upgrade/upgrade.test @@ -63,13 +63,13 @@ abstract class UpgradePathTestCase extends WebTestBase { } /** - * Overrides Drupal\simpletest\WebTestBase::setUp() for upgrade testing. + * Overrides Drupal\simpletest\WebTestBase::setUpBeforeClass() for upgrade testing. * * @see Drupal\simpletest\WebTestBase::prepareDatabasePrefix() * @see Drupal\simpletest\WebTestBase::changeDatabasePrefix() * @see Drupal\simpletest\WebTestBase::prepareEnvironment() */ - protected function setUp() { + protected function setUpBeforeClass() { global $user, $language_interface, $conf; // Load the Update API. @@ -298,12 +298,12 @@ class BareMinimalUpgradePath extends UpgradePathTestCase { ); } - public function setUp() { + public function setUpBeforeClass() { // Path to the database dump files. $this->databaseDumpFiles = array( drupal_get_path('module', 'system') . '/tests/upgrade/drupal-7.bare.minimal.database.php.gz', ); - parent::setUp(); + parent::setUpBeforeClass(); } /** @@ -377,12 +377,12 @@ class FilledMinimalUpgradePath extends UpgradePathTestCase { ); } - public function setUp() { + public function setUpBeforeClass() { // Path to the database dump files. $this->databaseDumpFiles = array( drupal_get_path('module', 'system') . '/tests/upgrade/drupal-7.filled.minimal.database.php.gz', ); - parent::setUp(); + parent::setUpBeforeClass(); } /** @@ -457,12 +457,12 @@ class BareStandardUpgradePath extends UpgradePathTestCase { ); } - public function setUp() { + public function setUpBeforeClass() { // Path to the database dump files. $this->databaseDumpFiles = array( drupal_get_path('module', 'system') . '/tests/upgrade/drupal-7.bare.standard_all.database.php.gz', ); - parent::setUp(); + parent::setUpBeforeClass(); } /** @@ -537,12 +537,12 @@ class FilledStandardUpgradePath extends UpgradePathTestCase { ); } - public function setUp() { + public function setUpBeforeClass() { // Path to the database dump files. $this->databaseDumpFiles = array( drupal_get_path('module', 'system') . '/tests/upgrade/drupal-7.filled.standard_all.database.php.gz', ); - parent::setUp(); + parent::setUpBeforeClass(); } /** diff --git a/core/modules/system/tests/uuid.test b/core/modules/system/tests/uuid.test index af7bcc7..6db741b 100644 --- a/core/modules/system/tests/uuid.test +++ b/core/modules/system/tests/uuid.test @@ -23,10 +23,10 @@ class UuidUnitTestCase extends UnitTestBase { ); } - public function setUp() { + public function setUpBeforeClass() { // Initiate the generator. This will lazy-load uuid.inc. $this->uuid = new Uuid(); - parent::setUp(); + parent::setUpBeforeClass(); } /** diff --git a/core/modules/system/tests/xmlrpc.test b/core/modules/system/tests/xmlrpc.test index b5c07ca..4147793 100644 --- a/core/modules/system/tests/xmlrpc.test +++ b/core/modules/system/tests/xmlrpc.test @@ -95,8 +95,8 @@ class XMLRPCValidator1IncTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('xmlrpc_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('xmlrpc_test'); } /** @@ -210,8 +210,8 @@ class XMLRPCMessagesTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('xmlrpc_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('xmlrpc_test'); } /** diff --git a/core/modules/taxonomy/taxonomy.test b/core/modules/taxonomy/taxonomy.test index 4a3db65..1001805 100644 --- a/core/modules/taxonomy/taxonomy.test +++ b/core/modules/taxonomy/taxonomy.test @@ -14,13 +14,13 @@ use Drupal\entity\EntityFieldQuery; */ class TaxonomyWebTestCase extends WebTestBase { - function setUp() { + function setUpBeforeClass() { $modules = func_get_args(); if (isset($modules[0]) && is_array($modules[0])) { $modules = $modules[0]; } $modules[] = 'taxonomy'; - parent::setUp($modules); + parent::setUpBeforeClass($modules); // Create Basic page and Article node types. if ($this->profile != 'standard') { @@ -28,6 +28,13 @@ class TaxonomyWebTestCase extends WebTestBase { } } + function setUp() { + parent::setUp(); + // Delete any possibly created taxonomy terms. + $terms = taxonomy_term_load_multiple(FALSE); + taxonomy_term_delete_multiple(array_keys($terms)); + } + /** * Returns a new vocabulary with random properties. */ @@ -77,11 +84,15 @@ class TaxonomyVocabularyFunctionalTest extends TaxonomyWebTestCase { ); } + function setUpBeforeClass() { + parent::setUpBeforeClass(); + $this->admin_user = $this->drupalCreateUser(array('administer taxonomy')); + $this->vocabulary = $this->createVocabulary(); + } + function setUp() { parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array('administer taxonomy')); $this->drupalLogin($this->admin_user); - $this->vocabulary = $this->createVocabulary(); } /** @@ -151,22 +162,6 @@ class TaxonomyVocabularyFunctionalTest extends TaxonomyWebTestCase { } /** - * Test the vocabulary overview with no vocabularies. - */ - function testTaxonomyAdminNoVocabularies() { - // Delete all vocabularies. - $vocabularies = taxonomy_vocabulary_load_multiple(FALSE); - foreach ($vocabularies as $key => $vocabulary) { - taxonomy_vocabulary_delete($key); - } - // Confirm that no vocabularies are found in the database. - $this->assertFalse(taxonomy_vocabulary_load_multiple(FALSE), 'No vocabularies found in the database.'); - $this->drupalGet('admin/structure/taxonomy'); - // Check the default message for no vocabularies. - $this->assertText(t('No vocabularies available.'), 'No vocabularies were found.'); - } - - /** * Deleting a vocabulary. */ function testTaxonomyAdminDeletingVocabulary() { @@ -198,6 +193,21 @@ class TaxonomyVocabularyFunctionalTest extends TaxonomyWebTestCase { $this->assertFalse(taxonomy_vocabulary_load($vid), t('Vocabulary is not found in the database')); } + /** + * Test the vocabulary overview with no vocabularies. + */ + function testTaxonomyAdminNoVocabularies() { + // Delete all vocabularies. + $vocabularies = taxonomy_vocabulary_load_multiple(FALSE); + foreach ($vocabularies as $key => $vocabulary) { + taxonomy_vocabulary_delete($key); + } + // Confirm that no vocabularies are found in the database. + $this->assertFalse(taxonomy_vocabulary_load_multiple(FALSE), 'No vocabularies found in the database.'); + $this->drupalGet('admin/structure/taxonomy'); + // Check the default message for no vocabularies. + $this->assertText(t('No vocabularies available.'), 'No vocabularies were found.'); + } } /** @@ -213,13 +223,21 @@ class TaxonomyVocabularyUnitTest extends TaxonomyWebTestCase { ); } - function setUp() { - parent::setUp(array('field_test')); - $admin_user = $this->drupalCreateUser(array('create article content', 'administer taxonomy')); - $this->drupalLogin($admin_user); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('field_test')); + $this->admin_user = $this->drupalCreateUser(array('create article content', 'administer taxonomy')); $this->vocabulary = $this->createVocabulary(); } + function setUp() { + parent::setUp(); + $this->drupalLogin($this->admin_user); + // Recreate the vocabulary, if necessary. + if (!taxonomy_vocabulary_machine_name_load($this->vocabulary->machine_name)) { + $this->vocabulary = $this->createVocabulary(); + } + } + /** * Ensure that when an invalid vocabulary vid is loaded, it is possible * to load the same vid successfully if it subsequently becomes valid. @@ -510,8 +528,8 @@ class TaxonomyLegacyTestCase extends TaxonomyWebTestCase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); $this->admin_user = $this->drupalCreateUser(array('administer taxonomy', 'administer nodes', 'bypass node access')); $this->drupalLogin($this->admin_user); } @@ -548,10 +566,9 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); $this->admin_user = $this->drupalCreateUser(array('administer taxonomy', 'bypass node access')); - $this->drupalLogin($this->admin_user); $this->vocabulary = $this->createVocabulary(); $field = array( @@ -585,6 +602,14 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase { field_create_instance($this->instance); } + function setUp() { + parent::setUp(); + $this->drupalLogin($this->admin_user); + // Reset the field instance. + $instance = $this->instance; + field_update_instance($instance); + } + /** * Test terms in a single and multiple hierarchy. */ @@ -1033,10 +1058,9 @@ class TaxonomyRSSTestCase extends TaxonomyWebTestCase { ); } - function setUp() { - parent::setUp(array('node', 'field_ui')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('node', 'field_ui')); $this->admin_user = $this->drupalCreateUser(array('administer taxonomy', 'bypass node access', 'administer content types')); - $this->drupalLogin($this->admin_user); $this->vocabulary = $this->createVocabulary(); $field = array( @@ -1070,6 +1094,11 @@ class TaxonomyRSSTestCase extends TaxonomyWebTestCase { field_create_instance($this->instance); } + function setUp() { + parent::setUp(); + $this->drupalLogin($this->admin_user); + } + /** * Tests that terms added to nodes are displayed in core RSS feed. * @@ -1127,12 +1156,11 @@ class TaxonomyTermIndexTestCase extends TaxonomyWebTestCase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); // Create an administrative user. $this->admin_user = $this->drupalCreateUser(array('administer taxonomy', 'bypass node access')); - $this->drupalLogin($this->admin_user); // Create a vocabulary and add two term reference fields to article nodes. $this->vocabulary = $this->createVocabulary(); @@ -1198,6 +1226,11 @@ class TaxonomyTermIndexTestCase extends TaxonomyWebTestCase { field_create_instance($this->instance_2); } + function setUp() { + parent::setUp(); + $this->drupalLogin($this->admin_user); + } + /** * Tests that the taxonomy index is maintained properly. */ @@ -1338,9 +1371,13 @@ class TaxonomyLoadMultipleUnitTest extends TaxonomyWebTestCase { ); } + function setUpBeforeClass() { + parent::setUpBeforeClass(); + $this->taxonomy_admin = $this->drupalCreateUser(array('administer taxonomy')); + } + function setUp() { parent::setUp(); - $this->taxonomy_admin = $this->drupalCreateUser(array('administer taxonomy')); $this->drupalLogin($this->taxonomy_admin); } @@ -1406,10 +1443,14 @@ class TaxonomyHooksTestCase extends TaxonomyWebTestCase { ); } + function setUpBeforeClass() { + parent::setUpBeforeClass(array('taxonomy_test')); + $this->admin_user = $this->drupalCreateUser(array('administer taxonomy')); + } + function setUp() { - parent::setUp(array('taxonomy_test')); - $taxonomy_admin = $this->drupalCreateUser(array('administer taxonomy')); - $this->drupalLogin($taxonomy_admin); + parent::setUp(); + $this->drupalLogin($this->admin_user); } /** @@ -1462,11 +1503,10 @@ class TaxonomyTermFieldTestCase extends TaxonomyWebTestCase { ); } - function setUp() { - parent::setUp('field_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('field_test'); - $web_user = $this->drupalCreateUser(array('access field_test content', 'administer field_test content', 'administer taxonomy')); - $this->drupalLogin($web_user); + $this->web_user = $this->drupalCreateUser(array('access field_test content', 'administer field_test content', 'administer taxonomy')); $this->vocabulary = $this->createVocabulary(); // Setup a field and instance. @@ -1500,6 +1540,11 @@ class TaxonomyTermFieldTestCase extends TaxonomyWebTestCase { field_create_instance($this->instance); } + function setUp() { + parent::setUp(); + $this->drupalLogin($this->web_user); + } + /** * Test term field validation. */ @@ -1562,6 +1607,12 @@ class TaxonomyTermFieldTestCase extends TaxonomyWebTestCase { taxonomy_vocabulary_delete($this->vocabulary->vid); $this->drupalGet('test-entity/add/test_bundle'); $this->assertNoFieldByName("{$this->field_name}[$langcode]", '', 'Widget is not displayed'); + + // Recreate it. + $this->vocabulary->enforceIsNew(); + taxonomy_vocabulary_save($this->vocabulary); + field_create_field($this->field); + field_create_instance($this->instance); } /** @@ -1617,11 +1668,10 @@ class TaxonomyTermFieldMultipleVocabularyTestCase extends TaxonomyWebTestCase { ); } - function setUp() { - parent::setUp('field_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('field_test'); - $web_user = $this->drupalCreateUser(array('access field_test content', 'administer field_test content', 'administer taxonomy')); - $this->drupalLogin($web_user); + $this->web_user = $this->drupalCreateUser(array('access field_test content', 'administer field_test content', 'administer taxonomy')); $this->vocabulary1 = $this->createVocabulary(); $this->vocabulary2 = $this->createVocabulary(); @@ -1661,6 +1711,11 @@ class TaxonomyTermFieldMultipleVocabularyTestCase extends TaxonomyWebTestCase { field_create_instance($this->instance); } + function setUp() { + parent::setUp(); + $this->drupalLogin($this->web_user); + } + /** * Tests term reference field and widget with multiple vocabularies. */ @@ -1735,10 +1790,9 @@ class TaxonomyTokenReplaceTestCase extends TaxonomyWebTestCase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); $this->admin_user = $this->drupalCreateUser(array('administer taxonomy', 'bypass node access')); - $this->drupalLogin($this->admin_user); $this->vocabulary = $this->createVocabulary(); $this->langcode = LANGUAGE_NOT_SPECIFIED; @@ -1773,6 +1827,11 @@ class TaxonomyTokenReplaceTestCase extends TaxonomyWebTestCase { field_create_instance($this->instance); } + function setUp() { + parent::setUp(); + $this->drupalLogin($this->admin_user); + } + /** * Creates some terms and a node, then tests the tokens generated from them. */ @@ -1882,8 +1941,8 @@ class TaxonomyThemeTestCase extends TaxonomyWebTestCase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); // Make sure we are using distinct default and administrative themes for // the duration of these tests. @@ -1892,8 +1951,12 @@ class TaxonomyThemeTestCase extends TaxonomyWebTestCase { // Create and log in as a user who has permission to add and edit taxonomy // terms and view the administrative theme. - $admin_user = $this->drupalCreateUser(array('administer taxonomy', 'view the administration theme')); - $this->drupalLogin($admin_user); + $this->admin_user = $this->drupalCreateUser(array('administer taxonomy', 'view the administration theme')); + } + + function setUp() { + parent::setUp(); + $this->drupalLogin($this->admin_user); } /** @@ -1930,11 +1993,15 @@ class TaxonomyEFQTestCase extends TaxonomyWebTestCase { ); } + function setUpBeforeClass() { + parent::setUpBeforeClass(); + $this->admin_user = $this->drupalCreateUser(array('administer taxonomy')); + $this->vocabulary = $this->createVocabulary(); + } + function setUp() { parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array('administer taxonomy')); $this->drupalLogin($this->admin_user); - $this->vocabulary = $this->createVocabulary(); } /** diff --git a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php index 2706d3b..4e989d2 100644 --- a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php +++ b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php @@ -36,8 +36,8 @@ class TrackerTest extends WebTestBase { ); } - function setUp() { - parent::setUp('comment', 'tracker'); + function setUpBeforeClass() { + parent::setUpBeforeClass('comment', 'tracker'); $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); diff --git a/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php b/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php index 19e7a38..cd1cba9 100644 --- a/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php +++ b/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php @@ -26,8 +26,8 @@ class TranslationTest extends WebTestBase { ); } - function setUp() { - parent::setUp('language', 'locale', 'translation', 'translation_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('language', 'locale', 'translation', 'translation_test'); // Setup users. $this->admin_user = $this->drupalCreateUser(array('bypass node access', 'administer nodes', 'administer languages', 'administer content types', 'administer blocks', 'access administration pages', 'translate content')); @@ -54,7 +54,9 @@ class TranslationTest extends WebTestBase { // Reset static caches in our local language environment. $this->resetCaches(); + } + function setUp() { $this->drupalLogin($this->translator); } diff --git a/core/modules/update/update.test b/core/modules/update/update.test index 0e10057..c5dc08d 100644 --- a/core/modules/update/update.test +++ b/core/modules/update/update.test @@ -65,8 +65,8 @@ class UpdateCoreTestCase extends UpdateTestHelper { ); } - function setUp() { - parent::setUp('update_test', 'update'); + function setUpBeforeClass() { + parent::setUpBeforeClass('update_test', 'update'); $admin_user = $this->drupalCreateUser(array('administer site configuration', 'administer modules')); $this->drupalLogin($admin_user); } @@ -276,8 +276,8 @@ class UpdateTestContribCase extends UpdateTestHelper { ); } - function setUp() { - parent::setUp('update_test', 'update', 'aaa_update_test', 'bbb_update_test', 'ccc_update_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('update_test', 'update', 'aaa_update_test', 'bbb_update_test', 'ccc_update_test'); $admin_user = $this->drupalCreateUser(array('administer site configuration')); $this->drupalLogin($admin_user); } @@ -640,8 +640,8 @@ class UpdateTestUploadCase extends UpdateTestHelper { ); } - public function setUp() { - parent::setUp('update', 'update_test'); + public function setUpBeforeClass() { + parent::setUpBeforeClass('update', 'update_test'); variable_set('allow_authorize_operations', TRUE); $admin_user = $this->drupalCreateUser(array('administer software updates', 'administer site configuration')); $this->drupalLogin($admin_user); @@ -738,8 +738,8 @@ class UpdateCoreUnitTestCase extends UnitTestBase { ); } - function setUp() { - parent::setUp('update'); + function setUpBeforeClass() { + parent::setUpBeforeClass('update'); module_load_include('inc', 'update', 'update.fetch'); } diff --git a/core/modules/user/user.test b/core/modules/user/user.test index 57a3713..9f476f4 100644 --- a/core/modules/user/user.test +++ b/core/modules/user/user.test @@ -16,8 +16,13 @@ class UserRegistrationTestCase extends WebTestBase { ); } + function setUpBeforeClass() { + parent::setUpBeforeClass('field_test'); + } + function setUp() { - parent::setUp('field_test'); + variable_set('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL); + variable_del('user_email_verification'); } function testRegistrationWithEmailVerification() { @@ -108,6 +113,8 @@ class UserRegistrationTestCase extends WebTestBase { // Login after administrator approval. $this->drupalPost('user/login', $auth, t('Log in')); $this->assertText(t('Member for'), t('User can log in after administrator approval.')); + + $this->drupalLogout(); } function testRegistrationEmailDuplicates() { @@ -172,6 +179,8 @@ class UserRegistrationTestCase extends WebTestBase { $this->assertEqual($new_user->preferred_langcode, language_default()->langcode, t('Correct preferred language field.')); $this->assertEqual($new_user->picture, 0, t('Correct picture field.')); $this->assertEqual($new_user->init, $mail, t('Correct init field.')); + + $this->drupalLogout(); } /** @@ -506,8 +515,8 @@ class UserCancelTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('comment'); + function setUpBeforeClass() { + parent::setUpBeforeClass('comment'); } /** @@ -643,18 +652,18 @@ class UserCancelTestCase extends WebTestBase { $this->assertNoText(t('Select the method to cancel the account above.'), t('Does not allow user to select account cancellation method.')); // Confirm account cancellation. - $timestamp = time(); - $this->drupalPost(NULL, NULL, t('Cancel account')); $this->assertText(t('A confirmation request to cancel your account has been sent to your e-mail address.'), t('Account cancellation request mailed message displayed.')); + $url = $this->assertCancelConfirmMail(); // Confirm account cancellation request. - $this->drupalGet("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login)); + $this->drupalGet($url); $account = user_load($account->uid, TRUE); $this->assertTrue($account->status == 0, t('User has been blocked.')); // Confirm user is logged out. $this->assertNoText($account->name, t('Logged out.')); + $this->loggedInUser = FALSE; } /** @@ -682,12 +691,12 @@ class UserCancelTestCase extends WebTestBase { $this->assertText(t('Your account will be blocked and you will no longer be able to log in. All of your content will be hidden from everyone but administrators.'), t('Informs that all content will be unpublished.')); // Confirm account cancellation. - $timestamp = time(); $this->drupalPost(NULL, NULL, t('Cancel account')); $this->assertText(t('A confirmation request to cancel your account has been sent to your e-mail address.'), t('Account cancellation request mailed message displayed.')); + $url = $this->assertCancelConfirmMail(); // Confirm account cancellation request. - $this->drupalGet("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login)); + $this->drupalGet($url); $account = user_load($account->uid, TRUE); $this->assertTrue($account->status == 0, t('User has been blocked.')); @@ -699,6 +708,7 @@ class UserCancelTestCase extends WebTestBase { // Confirm user is logged out. $this->assertNoText($account->name, t('Logged out.')); + $this->loggedInUser = FALSE; } /** @@ -732,12 +742,12 @@ class UserCancelTestCase extends WebTestBase { $this->assertRaw(t('Your account will be removed and all account information deleted. All of your content will be assigned to the %anonymous-name user.', array('%anonymous-name' => variable_get('anonymous', t('Anonymous')))), t('Informs that all content will be attributed to anonymous account.')); // Confirm account cancellation. - $timestamp = time(); $this->drupalPost(NULL, NULL, t('Cancel account')); $this->assertText(t('A confirmation request to cancel your account has been sent to your e-mail address.'), t('Account cancellation request mailed message displayed.')); + $url = $this->assertCancelConfirmMail(); // Confirm account cancellation request. - $this->drupalGet("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login)); + $this->drupalGet($url); $this->assertFalse(user_load($account->uid, TRUE), t('User is not found in the database.')); // Confirm that user's content has been attributed to anonymous user. @@ -750,6 +760,7 @@ class UserCancelTestCase extends WebTestBase { // Confirm that user is logged out. $this->assertNoText($account->name, t('Logged out.')); + $this->loggedInUser = FALSE; } /** @@ -796,12 +807,12 @@ class UserCancelTestCase extends WebTestBase { $this->assertText(t('Your account will be removed and all account information deleted. All of your content will also be deleted.'), t('Informs that all content will be deleted.')); // Confirm account cancellation. - $timestamp = time(); $this->drupalPost(NULL, NULL, t('Cancel account')); $this->assertText(t('A confirmation request to cancel your account has been sent to your e-mail address.'), t('Account cancellation request mailed message displayed.')); + $url = $this->assertCancelConfirmMail(); // Confirm account cancellation request. - $this->drupalGet("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login)); + $this->drupalGet($url); $this->assertFalse(user_load($account->uid, TRUE), t('User is not found in the database.')); // Confirm that user's content has been deleted. @@ -812,6 +823,7 @@ class UserCancelTestCase extends WebTestBase { // Confirm that user is logged out. $this->assertNoText($account->name, t('Logged out.')); + $this->loggedInUser = FALSE; } /** @@ -919,6 +931,20 @@ class UserCancelTestCase extends WebTestBase { $user1 = user_load(1, TRUE); $this->assertEqual($user1->status, 1, t('User #1 still exists and is not blocked.')); } + + /** + * Asserts that the last sent e-mail contains a link to cancel an account and returns it. + */ + protected function assertCancelConfirmMail() { + $mails = $this->drupalGetMails(); + $mail = end($mails); + $found = FALSE; + if (preg_match('@http.+user/\d+/cancel/confirm/\d+/[^\s]+@', $mail['body'], $matches)) { + $found = $matches[0]; + } + $this->assertTrue($found, t('Account cancellation e-mail link found: %url', array('%url' => $found))); + return $found; + } } class UserPictureTestCase extends WebTestBase { @@ -933,8 +959,8 @@ class UserPictureTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('image')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('image')); // Enable user pictures. variable_set('user_pictures', 1); @@ -1242,8 +1268,8 @@ class UserPermissionsTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); $this->admin_user = $this->drupalCreateUser(array('administer permissions', 'access user profiles', 'administer site configuration', 'administer modules', 'administer users')); @@ -1337,8 +1363,8 @@ class UserAdminTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('taxonomy')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('taxonomy')); } /** @@ -1486,8 +1512,8 @@ class UserAutocompleteTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); // Set up two users with different permissions to test access. $this->unprivileged_user = $this->drupalCreateUser(); @@ -1576,8 +1602,8 @@ class UserBlocksUnitTests extends WebTestBase { ); } - function setUp() { - parent::setUp(array('block')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('block')); // Enable user login block. db_merge('block') @@ -1625,6 +1651,8 @@ class UserBlocksUnitTests extends WebTestBase { $this->drupalPost('http://example.com/', $edit, t('Log in'), array('external' => FALSE)); // Check that we remain on the site after login. $this->assertEqual(url('user/' . $user->uid, array('absolute' => TRUE)), $this->getUrl(), t('Redirected to user profile page after login from the frontpage')); + + $this->drupalLogout(); } /** @@ -1871,8 +1899,8 @@ class UserSignatureTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('comment'); + function setUpBeforeClass() { + parent::setUpBeforeClass('comment'); // Enable user signatures. variable_set('user_signatures', 1); @@ -2012,8 +2040,8 @@ class UserRoleAdminTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); $this->admin_user = $this->drupalCreateUser(array('administer permissions', 'administer users')); } @@ -2161,8 +2189,8 @@ class UserUserSearchTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(array('search')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('search')); } function testUserSearch() { @@ -2199,8 +2227,8 @@ class UserRolesAssignmentTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp(); + function setUpBeforeClass() { + parent::setUpBeforeClass(); $this->admin_user = $this->drupalCreateUser(array('administer permissions', 'administer users')); $this->drupalLogin($this->admin_user); } @@ -2357,8 +2385,8 @@ class UserValidateCurrentPassCustomForm extends WebTestBase { */ protected $adminUser; - function setUp() { - parent::setUp('user_form_test'); + function setUpBeforeClass() { + parent::setUpBeforeClass('user_form_test'); // Create two users $this->accessUser = $this->drupalCreateUser(array('access content')); $this->adminUser = $this->drupalCreateUser(array('administer users')); @@ -2391,8 +2419,8 @@ class UserEntityCallbacksTestCase extends WebTestBase { ); } - function setUp() { - parent::setUp('user'); + function setUpBeforeClass() { + parent::setUpBeforeClass('user'); $this->account = $this->drupalCreateUser(); $this->anonymous = drupal_anonymous_user(); @@ -2431,8 +2459,8 @@ class UserLanguageFunctionalTest extends WebTestBase { ); } - function setUp() { - parent::setUp(array('user', 'language')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('user', 'language')); } /** @@ -2497,8 +2525,8 @@ class UserLanguageCreationTest extends WebTestBase { ); } - function setUp() { - parent::setUp(array('user', 'language')); + function setUpBeforeClass() { + parent::setUpBeforeClass(array('user', 'language')); variable_set('user_register', USER_REGISTER_VISITORS); }