From aab8b66a299ee4decbf6ac4662ce04d7e7cce111 Mon Sep 17 00:00:00 2001 From: catch <catch@35733.no-reply.drupal.org> Date: Tue, 13 Mar 2012 12:16:40 +0900 Subject: [PATCH] Issue #1373142 by sun, beejeebus, aspilicious, amateescu: Use the Testing profile. Speed up testbot by 50%. --- core/modules/aggregator/aggregator.test | 8 +- core/modules/block/block.test | 81 ++++++++--- core/modules/book/book.test | 2 +- core/modules/comment/comment.test | 2 + core/modules/contextual/contextual.test | 2 - core/modules/dashboard/dashboard.test | 43 ++++-- core/modules/dblog/dblog.test | 2 + .../field_sql_storage/field_sql_storage.test | 2 +- .../field/modules/list/tests/list.test | 4 +- core/modules/field/modules/number/number.test | 2 +- .../field/modules/options/options.test | 5 +- core/modules/field/modules/text/text.test | 4 + core/modules/field/tests/field.test | 2 +- core/modules/field_ui/field_ui.test | 8 +- core/modules/file/tests/file.test | 2 + core/modules/filter/filter.test | 21 ++- core/modules/forum/forum.test | 6 +- core/modules/help/help.test | 3 + core/modules/image/image.test | 41 ++++-- core/modules/locale/locale.test | 49 +++++-- core/modules/menu/menu.test | 4 + core/modules/node/node.test | 93 ++++++++----- core/modules/openid/openid.test | 31 +++++ core/modules/path/path.test | 35 ++++- core/modules/php/php.test | 5 +- core/modules/poll/poll.test | 65 ++++----- core/modules/rdf/rdf.test | 6 + core/modules/search/search.test | 121 ++++++++-------- core/modules/shortcut/shortcut.install | 7 +- core/modules/shortcut/shortcut.test | 10 ++ .../simpletest/drupal_web_test_case.php | 2 +- core/modules/simpletest/simpletest.test | 4 +- core/modules/simpletest/tests/ajax.test | 4 +- core/modules/simpletest/tests/bootstrap.test | 5 +- core/modules/simpletest/tests/common.test | 14 +- .../simpletest/tests/database_test.test | 2 - core/modules/simpletest/tests/file.test | 14 ++ core/modules/simpletest/tests/form.test | 20 ++- .../modules/simpletest/tests/form_test.module | 28 ++-- core/modules/simpletest/tests/image.test | 4 + core/modules/simpletest/tests/menu.test | 80 ++++++----- core/modules/simpletest/tests/module.test | 3 + core/modules/simpletest/tests/password.test | 2 - core/modules/simpletest/tests/theme.test | 11 +- core/modules/statistics/statistics.test | 27 +++- core/modules/system/system.module | 1 - core/modules/system/system.test | 129 ++++++++++-------- core/modules/taxonomy/taxonomy.test | 37 +++-- core/modules/tracker/tracker.test | 4 +- core/modules/translation/translation.test | 2 + core/modules/user/user.test | 69 +++++++++- profiles/testing/testing.info | 2 + profiles/testing/testing.install | 5 + 53 files changed, 769 insertions(+), 366 deletions(-) diff --git a/core/modules/aggregator/aggregator.test b/core/modules/aggregator/aggregator.test index 5e16ba0b1609..2149bed535e4 100644 --- a/core/modules/aggregator/aggregator.test +++ b/core/modules/aggregator/aggregator.test @@ -7,7 +7,13 @@ class AggregatorTestCase extends DrupalWebTestCase { function setUp() { - parent::setUp('aggregator', 'aggregator_test'); + parent::setUp(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); } diff --git a/core/modules/block/block.test b/core/modules/block/block.test index dbd7dc489e84..4af6240b20db 100644 --- a/core/modules/block/block.test +++ b/core/modules/block/block.test @@ -18,11 +18,19 @@ class BlockTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp(); + parent::setUp(array('block')); + + // Create Full HTML text format. + $full_html_format = array( + 'format' => 'full_html', + 'name' => 'Full HTML', + ); + $full_html_format = (object) $full_html_format; + filter_format_save($full_html_format); + $this->checkPermissions(array(), TRUE); // Create and log in an administrative user having access to the Full HTML // text format. - $full_html_format = filter_format_load('full_html'); $this->admin_user = $this->drupalCreateUser(array( 'administer blocks', filter_permission_name($full_html_format), @@ -43,6 +51,9 @@ class BlockTestCase extends DrupalWebTestCase { * Test creating custom block, moving it to a specific region and then deleting it. */ function testCustomBlock() { + // Enable a second theme. + theme_enable(array('seven')); + // Confirm that the add block link appears on block overview pages. $this->drupalGet('admin/structure/block'); $this->assertRaw(l('Add block', 'admin/structure/block/add'), t('Add block link is present on block overview page for default theme.')); @@ -51,7 +62,7 @@ class BlockTestCase extends DrupalWebTestCase { // Confirm that hidden regions are not shown as options for block placement // when adding a new block. - theme_enable(array('stark')); + theme_enable(array('bartik')); $themes = list_themes(); $this->drupalGet('admin/structure/block/add'); foreach ($themes as $key => $theme) { @@ -150,6 +161,10 @@ class BlockTestCase extends DrupalWebTestCase { * Test block visibility. */ function testBlockVisibility() { + // Enable Node module and change the front page path to 'node'. + module_enable(array('node')); + variable_set('site_frontpage', 'node'); + $block = array(); // Create a random title for the block @@ -171,7 +186,7 @@ class BlockTestCase extends DrupalWebTestCase { // authenticated users. $edit = array(); $edit['pages'] = 'user*'; - $edit['roles[2]'] = TRUE; + $edit['roles[' . DRUPAL_AUTHENTICATED_RID . ']'] = TRUE; $this->drupalPost('admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/configure', $edit, t('Save block')); // Move block to the first sidebar. @@ -392,14 +407,19 @@ class NonDefaultBlockAdmin extends DrupalWebTestCase { ); } + function setUp() { + parent::setUp(array('block')); + } + /** * Test non-default theme admin. */ function testNonDefaultBlockAdmin() { $admin_user = $this->drupalCreateUser(array('administer blocks', 'administer themes')); $this->drupalLogin($admin_user); - theme_enable(array('stark')); - $this->drupalGet('admin/structure/block/list/stark'); + $new_theme = 'bartik'; + theme_enable(array($new_theme)); + $this->drupalGet('admin/structure/block/list/' . $new_theme); } } @@ -415,6 +435,10 @@ class NewDefaultThemeBlocks extends DrupalWebTestCase { ); } + function setUp() { + parent::setUp(array('block')); + } + /** * Check the enabled Bartik blocks are correctly copied over. */ @@ -441,11 +465,12 @@ class NewDefaultThemeBlocks extends DrupalWebTestCase { $blocks[$block->module][$block->delta] = $block; } - // Turn on the Stark theme and ensure that it contains all of the blocks + // Turn on a new theme and ensure that it contains all of the blocks // the default theme had. - theme_enable(array('stark')); - variable_set('theme_default', 'stark'); - $result = db_query('SELECT * FROM {block} WHERE theme = :theme', array(':theme' => 'stark')); + $new_theme = 'bartik'; + theme_enable(array($new_theme)); + variable_set('theme_default', $new_theme); + $result = db_query('SELECT * FROM {block} WHERE theme = :theme', array(':theme' => $new_theme)); foreach ($result as $block) { unset($block->theme, $block->bid); $this->assertEqual($blocks[$block->module][$block->delta], $block, t('Block %name matched', array('%name' => $block->module . '-' . $block->delta))); @@ -465,6 +490,10 @@ class BlockAdminThemeTestCase extends DrupalWebTestCase { ); } + function setUp() { + parent::setUp(array('block')); + } + /** * Check for the accessibility of the admin theme on the block admin page. */ @@ -474,13 +503,13 @@ class BlockAdminThemeTestCase extends DrupalWebTestCase { $this->drupalLogin($admin_user); // Ensure that access to block admin page is denied when theme is disabled. - $this->drupalGet('admin/structure/block/list/stark'); + $this->drupalGet('admin/structure/block/list/bartik'); $this->assertResponse(403, t('The block admin page for a disabled theme can not be accessed')); // Enable admin theme and confirm that tab is accessible. - $edit['admin_theme'] = 'stark'; + $edit['admin_theme'] = 'bartik'; $this->drupalPost('admin/appearance', $edit, t('Save configuration')); - $this->drupalGet('admin/structure/block/list/stark'); + $this->drupalGet('admin/structure/block/list/bartik'); $this->assertResponse(200, t('The block admin page for the admin theme can be accessed')); } } @@ -502,7 +531,7 @@ class BlockCacheTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp('block_test'); + parent::setUp(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')); @@ -686,7 +715,7 @@ class BlockHTMLIdTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp('block_test'); + parent::setUp(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')); @@ -769,7 +798,23 @@ class BlockHiddenRegionTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp(array('block_test')); + parent::setUp(array('block', 'block_test', 'search')); + + // Enable Search block in default theme. + db_merge('block') + ->key(array( + 'module' => 'search', + 'delta' => 'form', + 'theme' => variable_get('theme_default', 'stark'), + )) + ->fields(array( + 'status' => 1, + 'weight' => -1, + 'region' => 'sidebar_first', + 'pages' => '', + 'cache' => -1, + )) + ->execute(); } /** @@ -780,6 +825,10 @@ class BlockHiddenRegionTestCase extends DrupalWebTestCase { $admin_user = $this->drupalCreateUser(array('administer blocks', 'administer themes', 'search content')); $this->drupalLogin($admin_user); + // Ensure that the search form block is displayed. + $this->drupalGet(''); + $this->assertText('Search', t('Block was displayed on the front page.')); + // Enable "block_test_theme" and set it as the default theme. $theme = 'block_test_theme'; theme_enable(array($theme)); diff --git a/core/modules/book/book.test b/core/modules/book/book.test index 6ca34ceeb9c4..54444b28d8f8 100644 --- a/core/modules/book/book.test +++ b/core/modules/book/book.test @@ -24,7 +24,7 @@ class BookTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp(array('book', 'node_access_test')); + parent::setUp(array('book', 'block', 'node_access_test')); // node_access_test requires a node_access_rebuild(). node_access_rebuild(); diff --git a/core/modules/comment/comment.test b/core/modules/comment/comment.test index 375d7550d384..925751398ed8 100644 --- a/core/modules/comment/comment.test +++ b/core/modules/comment/comment.test @@ -6,6 +6,8 @@ */ class CommentHelperCase extends DrupalWebTestCase { + protected $profile = 'standard'; + protected $admin_user; protected $web_user; protected $node; diff --git a/core/modules/contextual/contextual.test b/core/modules/contextual/contextual.test index 79eedb86f52e..734f7cf3c3d9 100644 --- a/core/modules/contextual/contextual.test +++ b/core/modules/contextual/contextual.test @@ -9,8 +9,6 @@ * Tests accessible links after inaccessible links on dynamic context. */ class ContextualDynamicContextTestCase extends DrupalWebTestCase { - protected $profile = 'testing'; - public static function getInfo() { return array( 'name' => 'Contextual links on node lists', diff --git a/core/modules/dashboard/dashboard.test b/core/modules/dashboard/dashboard.test index 56bdb132d229..ff37d5764249 100644 --- a/core/modules/dashboard/dashboard.test +++ b/core/modules/dashboard/dashboard.test @@ -18,21 +18,11 @@ class DashboardBlocksTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp(); + parent::setUp(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); - - // Make sure that the dashboard is using the same theme as the rest of the - // site (and in particular, the same theme used on 403 pages). This forces - // the dashboard blocks to be the same for an administrator as for a - // regular user, and therefore lets us test that the dashboard blocks - // themselves are specifically removed for a user who does not have access - // to the dashboard page. - theme_enable(array('stark')); - variable_set('theme_default', 'stark'); - variable_set('admin_theme', 'stark'); } /** @@ -65,6 +55,7 @@ class DashboardBlocksTestCase extends DrupalWebTestCase { */ function testDashboardRegions() { $dashboard_regions = dashboard_region_descriptions(); + $this->assertTrue(!empty($dashboard_regions), 'One or more dashboard regions found.'); // Ensure blocks can be placed in dashboard regions. $this->drupalGet('admin/dashboard/configure'); @@ -113,6 +104,36 @@ class DashboardBlocksTestCase extends DrupalWebTestCase { $this->drupalGet('admin/dashboard'); $this->assertRaw($custom_block['title'], t('Block still appears on the dashboard.')); } +} + +class DashboardBlockAvailabilityTestCase extends DrupalWebTestCase { + protected $profile = 'standard'; + + public static function getInfo() { + return array( + 'name' => 'Block availability', + 'description' => 'Test blocks as used by the dashboard.', + 'group' => 'Dashboard', + ); + } + + function setUp() { + parent::setUp(); + + // 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); + + // Make sure that the dashboard is using the same theme as the rest of the + // site (and in particular, the same theme used on 403 pages). This forces + // the dashboard blocks to be the same for an administrator as for a + // regular user, and therefore lets us test that the dashboard blocks + // themselves are specifically removed for a user who does not have access + // to the dashboard page. + theme_enable(array('stark')); + variable_set('theme_default', 'stark'); + variable_set('admin_theme', 'stark'); + } /** * Tests that administrative blocks are available for the dashboard. diff --git a/core/modules/dblog/dblog.test b/core/modules/dblog/dblog.test index 1ae26bc88c40..e3a997e25839 100644 --- a/core/modules/dblog/dblog.test +++ b/core/modules/dblog/dblog.test @@ -6,6 +6,8 @@ */ class DBLogTestCase extends DrupalWebTestCase { + protected $profile = 'standard'; + protected $big_user; protected $any_user; 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 e6459083e84c..83bef3516c33 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 @@ -23,7 +23,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp('field_sql_storage', 'field', 'field_test', 'text'); + parent::setUp('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 46ec97cc9319..988f6a3d1294 100644 --- a/core/modules/field/modules/list/tests/list.test +++ b/core/modules/field/modules/list/tests/list.test @@ -18,7 +18,7 @@ class ListFieldTestCase extends FieldTestCase { } function setUp() { - parent::setUp('field_test'); + parent::setUp(array('list', 'field_test')); $this->field_name = 'test_list'; $this->field = array( @@ -126,7 +126,7 @@ class ListFieldUITestCase extends FieldTestCase { } function setUp() { - parent::setUp('field_test', 'field_ui'); + parent::setUp(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 e39343e7db08..4a4f05f271f5 100644 --- a/core/modules/field/modules/number/number.test +++ b/core/modules/field/modules/number/number.test @@ -22,7 +22,7 @@ class NumberFieldTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp('field_test'); + parent::setUp(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 b0ec926e0dc4..b945949ffdbf 100644 --- a/core/modules/field/modules/options/options.test +++ b/core/modules/field/modules/options/options.test @@ -15,7 +15,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { } function setUp() { - parent::setUp('field_test', 'list_test'); + parent::setUp(array('list', 'field_test', 'list_test', 'taxonomy', 'field_ui')); // Field with cardinality 1. $this->card_1 = array( @@ -458,6 +458,9 @@ class OptionsWidgetsTestCase extends FieldTestCase { $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); $this->assertNoFieldChecked("edit-bool-$langcode"); + // Create Basic page node type. + $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); + // Create admin user. $admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer taxonomy')); $this->drupalLogin($admin_user); diff --git a/core/modules/field/modules/text/text.test b/core/modules/field/modules/text/text.test index 6360a18fde4f..0dbacccf3b21 100644 --- a/core/modules/field/modules/text/text.test +++ b/core/modules/field/modules/text/text.test @@ -238,6 +238,8 @@ class TextFieldTestCase extends DrupalWebTestCase { } class TextSummaryTestCase extends DrupalWebTestCase { + protected $profile = 'standard'; + public static function getInfo() { return array( 'name' => 'Text summary', @@ -406,6 +408,8 @@ class TextSummaryTestCase extends DrupalWebTestCase { } class TextTranslationTestCase extends DrupalWebTestCase { + protected $profile = 'standard'; + public static function getInfo() { return array( 'name' => 'Text translation', diff --git a/core/modules/field/tests/field.test b/core/modules/field/tests/field.test index 29c54249b600..3566484045a7 100644 --- a/core/modules/field/tests/field.test +++ b/core/modules/field/tests/field.test @@ -1286,7 +1286,7 @@ class FieldFormTestCase extends FieldTestCase { } function setUp() { - parent::setUp('field_test'); + parent::setUp(array('node', 'field_test', 'list')); $web_user = $this->drupalCreateUser(array('access field_test content', 'administer field_test content')); $this->drupalLogin($web_user); diff --git a/core/modules/field_ui/field_ui.test b/core/modules/field_ui/field_ui.test index 156b4554b01c..8c202e57d5fd 100644 --- a/core/modules/field_ui/field_ui.test +++ b/core/modules/field_ui/field_ui.test @@ -137,8 +137,6 @@ class FieldUITestCase extends DrupalWebTestCase { * Tests the functionality of the 'Manage fields' screen. */ class FieldUIManageFieldsTestCase extends FieldUITestCase { - protected $profile = 'testing'; - public static function getInfo() { return array( 'name' => 'Manage fields', @@ -710,7 +708,11 @@ class FieldUIAlterTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp(array('field_test')); + parent::setUp(array('field_ui', 'field_test', 'text', 'list')); + + // Create Article node type. + $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); + $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); // Create test user. $admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer users')); diff --git a/core/modules/file/tests/file.test b/core/modules/file/tests/file.test index c86890a7c9ca..05083fc517a1 100644 --- a/core/modules/file/tests/file.test +++ b/core/modules/file/tests/file.test @@ -9,6 +9,8 @@ * Provides methods specifically for testing File module's field handling. */ class FileFieldTestCase extends DrupalWebTestCase { + protected $profile = 'standard'; + protected $admin_user; function setUp() { diff --git a/core/modules/filter/filter.test b/core/modules/filter/filter.test index f6476f5e9df5..25ecb705b402 100644 --- a/core/modules/filter/filter.test +++ b/core/modules/filter/filter.test @@ -161,6 +161,8 @@ class FilterCRUDTestCase extends DrupalWebTestCase { } class FilterAdminTestCase extends DrupalWebTestCase { + protected $profile = 'standard'; + public static function getInfo() { return array( 'name' => 'Filter administration functionality', @@ -419,6 +421,8 @@ class FilterFormatAccessTestCase extends DrupalWebTestCase { function setUp() { parent::setUp(); + $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); + // Create a user who can administer text formats, but does not have // specific permission to use any of them. $this->filter_admin_user = $this->drupalCreateUser(array( @@ -739,7 +743,22 @@ class FilterSecurityTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp('php', 'filter_test'); + parent::setUp(array('node', 'php', 'filter_test')); + + // Create Basic page node type. + $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); + + // Create Filtered HTML format. + $filtered_html_format = array( + 'format' => 'filtered_html', + 'name' => 'Filtered HTML', + ); + $filtered_html_format = (object) $filtered_html_format; + filter_format_save($filtered_html_format); + + $filtered_html_permission = filter_permission_name($filtered_html_format); + user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array($filtered_html_permission)); + $this->admin_user = $this->drupalCreateUser(array('administer modules', 'administer filters', 'administer site configuration')); $this->drupalLogin($this->admin_user); } diff --git a/core/modules/forum/forum.test b/core/modules/forum/forum.test index f7392f419e23..b5b8ae4995a4 100644 --- a/core/modules/forum/forum.test +++ b/core/modules/forum/forum.test @@ -27,7 +27,7 @@ class ForumTestCase extends DrupalWebTestCase { * Enable modules and create users with specific permissions. */ function setUp() { - parent::setUp('taxonomy', 'comment', 'forum'); + parent::setUp(array('taxonomy', 'comment', 'forum', 'node', 'block', 'menu', 'help')); // Create users. $this->admin_user = $this->drupalCreateUser(array( 'access administration pages', @@ -49,7 +49,7 @@ class ForumTestCase extends DrupalWebTestCase { 'edit own forum content', 'delete own forum content', )); - $this->web_user = $this->drupalCreateUser(array()); + $this->web_user = $this->drupalCreateUser(); } /** @@ -147,7 +147,7 @@ class ForumTestCase extends DrupalWebTestCase { $this->assertFieldByXPath($xpath, '6', t('Number of posts found.')); // Test loading multiple forum nodes on the front page. - $this->drupalLogin($this->drupalCreateUser(array('administer content types', 'create forum content'))); + $this->drupalLogin($this->drupalCreateUser(array('administer content types', 'create forum content', 'post comments'))); $this->drupalPost('admin/structure/types/manage/forum', array('node_options[promote]' => 'promote'), t('Save content type')); $this->createForumTopic($this->forum, FALSE); $this->createForumTopic($this->forum, FALSE); diff --git a/core/modules/help/help.test b/core/modules/help/help.test index a37afb2e97dd..3e629264582b 100644 --- a/core/modules/help/help.test +++ b/core/modules/help/help.test @@ -9,6 +9,9 @@ * Tests help display and user access for all modules implementing help. */ class HelpTestCase extends DrupalWebTestCase { + // Tests help implementations of many arbitrary core modules. + protected $profile = 'standard'; + /** * The admin user that will be created. */ diff --git a/core/modules/image/image.test b/core/modules/image/image.test index 7455cf4d1a9b..2c422a754d51 100644 --- a/core/modules/image/image.test +++ b/core/modules/image/image.test @@ -32,7 +32,20 @@ class ImageFieldTestCase extends DrupalWebTestCase { protected $admin_user; function setUp() { - parent::setUp('image'); + $modules = func_get_args(); + if (isset($modules[0]) && is_array($modules[0])) { + $modules = $modules[0]; + } + $modules[] = 'node'; + $modules[] = 'image'; + parent::setUp($modules); + + // Create Basic page and Article node types. + if ($this->profile != 'standard') { + $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); + $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); + } + $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')); $this->drupalLogin($this->admin_user); } @@ -119,7 +132,7 @@ class ImageStylesPathAndUrlUnitTest extends DrupalWebTestCase { } function setUp() { - parent::setUp('image_module_test'); + parent::setUp(array('image', 'image_module_test')); $this->style_name = 'style_foo'; image_style_save(array('name' => $this->style_name)); @@ -566,6 +579,10 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase { ); } + function setUp() { + parent::setUp(array('field_ui')); + } + /** * Test image formatters on node display for public files. */ @@ -876,7 +893,7 @@ class ImageDimensionsUnitTest extends DrupalWebTestCase { } function setUp() { - parent::setUp('rdf', 'image', 'image_module_test'); + parent::setUp(array('image', 'image_module_test')); } /** @@ -917,7 +934,7 @@ class ImageDimensionsUnitTest extends DrupalWebTestCase { image_effect_save('test', $effect); $img_tag = theme_image_style($variables); - $this->assertEqual($img_tag, '<img typeof="foaf:Image" src="' . $url . '" width="120" height="60" alt="" />'); + $this->assertEqual($img_tag, '<img src="' . $url . '" width="120" height="60" alt="" />'); $this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.')); $this->drupalGet($url); $this->assertResponse(200, t('Image was generated at the URL.')); @@ -938,7 +955,7 @@ class ImageDimensionsUnitTest extends DrupalWebTestCase { image_effect_save('test', $effect); $img_tag = theme_image_style($variables); - $this->assertEqual($img_tag, '<img typeof="foaf:Image" src="' . $url . '" width="60" height="120" alt="" />'); + $this->assertEqual($img_tag, '<img src="' . $url . '" width="60" height="120" alt="" />'); $this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.')); $this->drupalGet($url); $this->assertResponse(200, t('Image was generated at the URL.')); @@ -960,7 +977,7 @@ class ImageDimensionsUnitTest extends DrupalWebTestCase { image_effect_save('test', $effect); $img_tag = theme_image_style($variables); - $this->assertEqual($img_tag, '<img typeof="foaf:Image" src="' . $url . '" width="45" height="90" alt="" />'); + $this->assertEqual($img_tag, '<img src="' . $url . '" width="45" height="90" alt="" />'); $this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.')); $this->drupalGet($url); $this->assertResponse(200, t('Image was generated at the URL.')); @@ -982,7 +999,7 @@ class ImageDimensionsUnitTest extends DrupalWebTestCase { image_effect_save('test', $effect); $img_tag = theme_image_style($variables); - $this->assertEqual($img_tag, '<img typeof="foaf:Image" src="' . $url . '" width="45" height="90" alt="" />'); + $this->assertEqual($img_tag, '<img src="' . $url . '" width="45" height="90" alt="" />'); $this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.')); $this->drupalGet($url); $this->assertResponse(200, t('Image was generated at the URL.')); @@ -1000,7 +1017,7 @@ class ImageDimensionsUnitTest extends DrupalWebTestCase { image_effect_save('test', $effect); $img_tag = theme_image_style($variables); - $this->assertEqual($img_tag, '<img typeof="foaf:Image" src="' . $url . '" width="45" height="90" alt="" />'); + $this->assertEqual($img_tag, '<img src="' . $url . '" width="45" height="90" alt="" />'); $this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.')); $this->drupalGet($url); $this->assertResponse(200, t('Image was generated at the URL.')); @@ -1021,7 +1038,7 @@ class ImageDimensionsUnitTest extends DrupalWebTestCase { image_effect_save('test', $effect); $img_tag = theme_image_style($variables); - $this->assertEqual($img_tag, '<img typeof="foaf:Image" src="' . $url . '" alt="" />'); + $this->assertEqual($img_tag, '<img src="' . $url . '" alt="" />'); $this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.')); $this->drupalGet($url); $this->assertResponse(200, t('Image was generated at the URL.')); @@ -1041,7 +1058,7 @@ class ImageDimensionsUnitTest extends DrupalWebTestCase { image_effect_save('test', $effect); $img_tag = theme_image_style($variables); - $this->assertEqual($img_tag, '<img typeof="foaf:Image" src="' . $url . '" width="30" height="30" alt="" />'); + $this->assertEqual($img_tag, '<img src="' . $url . '" width="30" height="30" alt="" />'); $this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.')); $this->drupalGet($url); $this->assertResponse(200, t('Image was generated at the URL.')); @@ -1062,7 +1079,7 @@ class ImageDimensionsUnitTest extends DrupalWebTestCase { $effect = image_effect_save('test', $effect); $img_tag = theme_image_style($variables); - $this->assertEqual($img_tag, '<img typeof="foaf:Image" src="' . $url . '" alt="" />'); + $this->assertEqual($img_tag, '<img src="' . $url . '" alt="" />'); $this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.')); $this->drupalGet($url); $this->assertResponse(200, t('Image was generated at the URL.')); @@ -1080,7 +1097,7 @@ class ImageDimensionsUnitTest extends DrupalWebTestCase { image_effect_save('test', $effect); $img_tag = theme_image_style($variables); - $this->assertEqual($img_tag, '<img typeof="foaf:Image" src="' . $url . '" alt="" />'); + $this->assertEqual($img_tag, '<img src="' . $url . '" alt="" />'); } } diff --git a/core/modules/locale/locale.test b/core/modules/locale/locale.test index c6598a1b40f3..f2395ad90d6f 100644 --- a/core/modules/locale/locale.test +++ b/core/modules/locale/locale.test @@ -56,7 +56,7 @@ class LocaleConfigurationTest extends DrupalWebTestCase { 'predefined_langcode' => 'fr', ); $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); - $this->assertText('fr', t('Language added successfully.')); + $this->assertText('French'); $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.')); // Check if the Default English language has no path prefix. @@ -915,7 +915,7 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase { protected $admin_user = NULL; function setUp() { - parent::setUp('locale', 'locale_test'); + parent::setUp(array('locale', 'locale_test', 'dblog')); // Set the translation file directory. variable_set('locale_translate_file_directory', drupal_get_path('module', 'locale_test')); @@ -1391,8 +1391,11 @@ class LocaleUninstallFunctionalTest extends DrupalWebTestCase { protected $language; function setUp() { - parent::setUp('locale'); + parent::setUp(array('node', 'locale')); $this->langcode = 'en'; + + // Create Article node type. + $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); } /** @@ -1533,7 +1536,7 @@ class LocaleLanguageSwitchingFunctionalTest extends DrupalWebTestCase { } function setUp() { - parent::setUp('locale'); + parent::setUp(array('locale', 'block')); // Create and login user. $admin_user = $this->drupalCreateUser(array('administer blocks', 'administer languages', 'translate interface', 'access administration pages')); @@ -1833,7 +1836,7 @@ class LocaleUserCreationTest extends DrupalWebTestCase { 'predefined_langcode' => 'fr', ); $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); - $this->assertText($langcode, t('Language added successfully.')); + $this->assertText('French', t('Language added successfully.')); $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.')); // Set language negotiation. @@ -1918,7 +1921,10 @@ class LocalePathFunctionalTest extends DrupalWebTestCase { } function setUp() { - parent::setUp('locale', 'path'); + parent::setUp(array('node', 'locale', 'path')); + + $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); + variable_set('site_frontpage', 'node'); } /** @@ -2003,8 +2009,8 @@ class LocalePathFunctionalTest extends DrupalWebTestCase { path_delete($edit); // Create language nodes to check priority of aliases. - $first_node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1)); - $second_node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1)); + $first_node = $this->drupalCreateNode(array('type' => 'page', 'promote' => 1)); + $second_node = $this->drupalCreateNode(array('type' => 'page', 'promote' => 1)); // Assign a custom path alias to the first node with the English language. $edit = array( @@ -2045,6 +2051,8 @@ class LocalePathFunctionalTest extends DrupalWebTestCase { * Functional tests for multilingual support on nodes. */ class LocaleContentFunctionalTest extends DrupalWebTestCase { + protected $profile = 'standard'; + public static function getInfo() { return array( 'name' => 'Content language settings', @@ -2296,7 +2304,7 @@ class LocaleUILanguageNegotiationTest extends DrupalWebTestCase { } function setUp() { - parent::setUp('locale', 'locale_test'); + parent::setUp(array('locale', 'locale_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')); @@ -2515,11 +2523,11 @@ class LocaleUILanguageNegotiationTest extends DrupalWebTestCase { // Check that the language switcher active link matches the given browser // language. $args = array(':url' => base_path() . (!empty($GLOBALS['conf']['clean_url']) ? $langcode_browser_fallback : "?q=$langcode_browser_fallback")); - $fields = $this->xpath('//div[@id="block-locale-language-interface"]//a[@class="language-link active" and @href=:url]', $args); + $fields = $this->xpath('//div[@id="block-locale-language-interface"]//a[@class="language-link active" and starts-with(@href, :url)]', $args); $this->assertTrue($fields[0] == $languages[$langcode_browser_fallback]->name, t('The browser language is the URL active language')); // Check that URLs are rewritten using the given browser language. - $fields = $this->xpath('//div[@id="site-name"]//a[@rel="home" and @href=:url]//span', $args); + $fields = $this->xpath('//p[@id="site-name"]/strong/a[@rel="home" and @href=:url]', $args); $this->assertTrue($fields[0] == 'Drupal', t('URLs are rewritten using the browser language.')); } @@ -2676,7 +2684,11 @@ class LocaleMultilingualFieldsFunctionalTest extends DrupalWebTestCase { } function setUp() { - parent::setUp('locale'); + parent::setUp(array('node', 'locale')); + + // Create Basic page node type. + $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); + // Setup users. $admin_user = $this->drupalCreateUser(array('administer languages', 'administer content types', 'access administration pages', 'create page content', 'edit own page content')); $this->drupalLogin($admin_user); @@ -2779,8 +2791,11 @@ class LocaleMultilingualFieldsFunctionalTest extends DrupalWebTestCase { // Check if node body is showed. $this->drupalGet("node/$node->nid"); - $body = $this->xpath('//div[@id=:id]//div[@property="content:encoded"]/p', array(':id' => 'node-' . $node->nid)); - $this->assertEqual(current($body), $node->body['en'][0]['value'], 'Node body is correctly showed.'); + $body = $this->xpath('//article[@id=:id]//div[@class=:class]/descendant::p', array( + ':id' => 'node-' . $node->nid, + ':class' => 'content', + )); + $this->assertEqual(current($body), $node->body['en'][0]['value'], 'Node body found.'); } } @@ -2788,6 +2803,7 @@ class LocaleMultilingualFieldsFunctionalTest extends DrupalWebTestCase { * Functional tests for comment language. */ class LocaleCommentLanguageFunctionalTest extends DrupalWebTestCase { + protected $profile = 'standard'; public static function getInfo() { return array( @@ -2892,7 +2908,10 @@ class LocaleDateFormatsFunctionalTest extends DrupalWebTestCase { } function setUp() { - parent::setUp('locale'); + parent::setUp(array('node', 'locale')); + + // Create Article node type. + $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); // Create and login user. $admin_user = $this->drupalCreateUser(array('administer site configuration', 'administer languages', 'access administration pages', 'create article content')); diff --git a/core/modules/menu/menu.test b/core/modules/menu/menu.test index 461a0dfb3879..e1f2aa9f45e8 100644 --- a/core/modules/menu/menu.test +++ b/core/modules/menu/menu.test @@ -6,6 +6,8 @@ */ class MenuTestCase extends DrupalWebTestCase { + protected $profile = 'standard'; + protected $big_user; protected $std_user; protected $menu; @@ -582,6 +584,8 @@ class MenuTestCase extends DrupalWebTestCase { * Test menu settings for nodes. */ class MenuNodeTestCase extends DrupalWebTestCase { + protected $profile = 'standard'; + public static function getInfo() { return array( 'name' => 'Menu settings for nodes', diff --git a/core/modules/node/node.test b/core/modules/node/node.test index 375531afe974..1dbcaf38f9fd 100644 --- a/core/modules/node/node.test +++ b/core/modules/node/node.test @@ -7,10 +7,27 @@ use Drupal\Core\Database\Database; * Tests for node.module. */ +class NodeWebTestCase extends DrupalWebTestCase { + function setUp() { + $modules = func_get_args(); + if (isset($modules[0]) && is_array($modules[0])) { + $modules = $modules[0]; + } + $modules[] = 'node'; + parent::setUp($modules); + + // Create Basic page and Article node types. + if ($this->profile != 'standard') { + $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); + $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); + } + } +} + /** * Tests the node_load_multiple() function. */ -class NodeLoadMultipleUnitTest extends DrupalWebTestCase { +class NodeLoadMultipleUnitTest extends NodeWebTestCase { public static function getInfo() { return array( @@ -90,7 +107,7 @@ class NodeLoadMultipleUnitTest extends DrupalWebTestCase { /** * Tests for the hooks invoked during node_load(). */ -class NodeLoadHooksTestCase extends DrupalWebTestCase { +class NodeLoadHooksTestCase extends NodeWebTestCase { public static function getInfo() { return array( 'name' => 'Node load hooks', @@ -131,7 +148,7 @@ class NodeLoadHooksTestCase extends DrupalWebTestCase { } } -class NodeRevisionsTestCase extends DrupalWebTestCase { +class NodeRevisionsTestCase extends NodeWebTestCase { protected $nodes; protected $logs; @@ -264,7 +281,7 @@ class NodeRevisionsTestCase extends DrupalWebTestCase { } } -class PageEditTestCase extends DrupalWebTestCase { +class PageEditTestCase extends NodeWebTestCase { protected $web_user; protected $admin_user; @@ -396,7 +413,7 @@ class PageEditTestCase extends DrupalWebTestCase { } } -class PagePreviewTestCase extends DrupalWebTestCase { +class PagePreviewTestCase extends NodeWebTestCase { public static function getInfo() { return array( 'name' => 'Node preview', @@ -467,7 +484,7 @@ class PagePreviewTestCase extends DrupalWebTestCase { } } -class NodeCreationTestCase extends DrupalWebTestCase { +class NodeCreationTestCase extends NodeWebTestCase { public static function getInfo() { return array( 'name' => 'Node creation', @@ -478,7 +495,7 @@ class NodeCreationTestCase extends DrupalWebTestCase { function setUp() { // Enable dummy module that implements hook_node_insert for exceptions. - parent::setUp('node_test_exception'); + parent::setUp(array('node_test_exception', 'dblog')); $web_user = $this->drupalCreateUser(array('create page content', 'edit own page content')); $this->drupalLogin($web_user); @@ -545,7 +562,7 @@ class NodeCreationTestCase extends DrupalWebTestCase { } } -class PageViewTestCase extends DrupalWebTestCase { +class PageViewTestCase extends NodeWebTestCase { public static function getInfo() { return array( 'name' => 'Node edit permissions', @@ -584,7 +601,7 @@ class PageViewTestCase extends DrupalWebTestCase { } } -class SummaryLengthTestCase extends DrupalWebTestCase { +class SummaryLengthTestCase extends NodeWebTestCase { public static function getInfo() { return array( 'name' => 'Summary length', @@ -626,7 +643,7 @@ class SummaryLengthTestCase extends DrupalWebTestCase { } } -class NodeTitleXSSTestCase extends DrupalWebTestCase { +class NodeTitleXSSTestCase extends NodeWebTestCase { public static function getInfo() { return array( 'name' => 'Node title XSS filtering', @@ -660,7 +677,7 @@ class NodeTitleXSSTestCase extends DrupalWebTestCase { } } -class NodeBlockTestCase extends DrupalWebTestCase { +class NodeBlockTestCase extends NodeWebTestCase { public static function getInfo() { return array( 'name' => 'Block availability', @@ -670,7 +687,7 @@ class NodeBlockTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp(); + parent::setUp(array('block')); // Create and login user $admin_user = $this->drupalCreateUser(array('administer blocks')); @@ -693,7 +710,7 @@ class NodeBlockTestCase extends DrupalWebTestCase { /** * Check that the post information displays when enabled for a content type. */ -class NodePostSettingsTestCase extends DrupalWebTestCase { +class NodePostSettingsTestCase extends NodeWebTestCase { public static function getInfo() { return array( 'name' => 'Node post information display', @@ -728,7 +745,7 @@ class NodePostSettingsTestCase extends DrupalWebTestCase { // Check that the post information is displayed. $node = $this->drupalGetNodeByTitle($edit["title"]); - $elements = $this->xpath('//div[contains(@class,:class)]', array(':class' => 'submitted')); + $elements = $this->xpath('//*[contains(@class,:class)]', array(':class' => 'submitted')); $this->assertEqual(count($elements), 1, t('Post information is displayed.')); } @@ -762,7 +779,7 @@ class NodePostSettingsTestCase extends DrupalWebTestCase { * added to the node->content array, then verify that the data appears on the * sitewide RSS feed at rss.xml. */ -class NodeRSSContentTestCase extends DrupalWebTestCase { +class NodeRSSContentTestCase extends NodeWebTestCase { public static function getInfo() { return array( 'name' => 'Node RSS Content', @@ -823,7 +840,7 @@ class NodeRSSContentTestCase extends DrupalWebTestCase { * @todo Cover hook_node_access in a separate test class. * hook_node_access_records is covered in another test class. */ -class NodeAccessUnitTest extends DrupalWebTestCase { +class NodeAccessUnitTest extends NodeWebTestCase { public static function getInfo() { return array( 'name' => 'Node access', @@ -890,7 +907,7 @@ class NodeAccessUnitTest extends DrupalWebTestCase { /** * Test case to verify hook_node_access_records functionality. */ -class NodeAccessRecordsUnitTest extends DrupalWebTestCase { +class NodeAccessRecordsUnitTest extends NodeWebTestCase { public static function getInfo() { return array( 'name' => 'Node access records', @@ -973,7 +990,9 @@ class NodeAccessRecordsUnitTest extends DrupalWebTestCase { /** * Tests for Node Access with a non-node base table. */ -class NodeAccessBaseTableTestCase extends DrupalWebTestCase { +class NodeAccessBaseTableTestCase extends NodeWebTestCase { + // Requires tags taxonomy field. + protected $profile = 'standard'; public static function getInfo() { return array( @@ -1132,7 +1151,7 @@ class NodeAccessBaseTableTestCase extends DrupalWebTestCase { /** * Test case to check node save related functionality, including import-save */ -class NodeSaveTestCase extends DrupalWebTestCase { +class NodeSaveTestCase extends NodeWebTestCase { public static function getInfo() { return array( @@ -1275,7 +1294,7 @@ class NodeSaveTestCase extends DrupalWebTestCase { /** * Tests related to node types. */ -class NodeTypeTestCase extends DrupalWebTestCase { +class NodeTypeTestCase extends NodeWebTestCase { public static function getInfo() { return array( 'name' => 'Node types', @@ -1284,6 +1303,10 @@ class NodeTypeTestCase extends DrupalWebTestCase { ); } + function setUp() { + parent::setUp(array('field_ui')); + } + /** * Ensure that node type functions (node_type_get_*) work correctly. * @@ -1378,7 +1401,7 @@ class NodeTypeTestCase extends DrupalWebTestCase { $this->assertRaw('Body', t('Body field was found.')); // Remove the body field. - $this->drupalPost('admin/structure/types/manage/bar/fields/body/delete', NULL, t('Delete')); + $this->drupalPost('admin/structure/types/manage/bar/fields/body/delete', array(), t('Delete')); // Resave the settings for this type. $this->drupalPost('admin/structure/types/manage/bar', array(), t('Save content type')); // Check that the body field doesn't exist. @@ -1429,7 +1452,7 @@ class NodeTypeTestCase extends DrupalWebTestCase { /** * Test node type customizations persistence. */ -class NodeTypePersistenceTestCase extends DrupalWebTestCase { +class NodeTypePersistenceTestCase extends NodeWebTestCase { public static function getInfo() { return array( 'name' => 'Node type persist', @@ -1505,7 +1528,7 @@ class NodeTypePersistenceTestCase extends DrupalWebTestCase { /** * Rebuild the node_access table. */ -class NodeAccessRebuildTestCase extends DrupalWebTestCase { +class NodeAccessRebuildTestCase extends NodeWebTestCase { public static function getInfo() { return array( 'name' => 'Node access rebuild', @@ -1533,7 +1556,7 @@ class NodeAccessRebuildTestCase extends DrupalWebTestCase { /** * Test node administration page functionality. */ -class NodeAdminTestCase extends DrupalWebTestCase { +class NodeAdminTestCase extends NodeWebTestCase { public static function getInfo() { return array( 'name' => 'Node administration', @@ -1698,7 +1721,7 @@ class NodeAdminTestCase extends DrupalWebTestCase { /** * Test node title. */ -class NodeTitleTestCase extends DrupalWebTestCase { +class NodeTitleTestCase extends NodeWebTestCase { protected $admin_user; public static function getInfo() { @@ -1710,8 +1733,8 @@ class NodeTitleTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array('administer nodes', 'create article content', 'create page content')); + parent::setUp(array('comment')); + $this->admin_user = $this->drupalCreateUser(array('administer nodes', 'create article content', 'create page content', 'post comments')); $this->drupalLogin($this->admin_user); } @@ -1738,7 +1761,7 @@ class NodeTitleTestCase extends DrupalWebTestCase { $this->assertEqual(current($this->xpath($xpath)), $node->title, 'Node breadcrumb is equal to node title.', 'Node'); // Test node title in comment preview. - $this->assertEqual(current($this->xpath('//div[@id=:id]/h2/a', array(':id' => 'node-' . $node->nid))), $node->title, 'Node preview title is equal to node title.', 'Node'); + $this->assertEqual(current($this->xpath('//article[@id=:id]/h2/a', array(':id' => 'node-' . $node->nid))), $node->title, 'Node preview title is equal to node title.', 'Node'); // Test node title is clickable on teaser list (/node). $this->drupalGet('node'); @@ -1773,7 +1796,7 @@ class NodeFeedTestCase extends DrupalWebTestCase { /** * Functional tests for the node module blocks. */ -class NodeBlockFunctionalTest extends DrupalWebTestCase { +class NodeBlockFunctionalTest extends NodeWebTestCase { public static function getInfo() { return array( 'name' => 'Node blocks', @@ -1783,7 +1806,7 @@ class NodeBlockFunctionalTest extends DrupalWebTestCase { } function setUp() { - parent::setUp('node', 'block'); + parent::setUp(array('block')); // Create users and test node. $this->admin_user = $this->drupalCreateUser(array('administer content types', 'administer nodes', 'administer blocks')); @@ -1946,7 +1969,7 @@ class MultiStepNodeFormBasicOptionsTest extends DrupalWebTestCase { /** * Test to ensure that a node's content is always rebuilt. */ -class NodeBuildContent extends DrupalWebTestCase { +class NodeBuildContent extends NodeWebTestCase { public static function getInfo() { return array( @@ -1974,7 +1997,7 @@ class NodeBuildContent extends DrupalWebTestCase { /** * Tests node_query_node_access_alter(). */ -class NodeQueryAlter extends DrupalWebTestCase { +class NodeQueryAlter extends NodeWebTestCase { public static function getInfo() { return array( @@ -2165,7 +2188,7 @@ class NodeQueryAlter extends DrupalWebTestCase { /** * Tests node_query_entity_field_access_alter(). */ -class NodeEntityFieldQueryAlter extends DrupalWebTestCase { +class NodeEntityFieldQueryAlter extends NodeWebTestCase { public static function getInfo() { return array( @@ -2229,7 +2252,7 @@ class NodeEntityFieldQueryAlter extends DrupalWebTestCase { /** * Test node token replacement in strings. */ -class NodeTokenReplaceTestCase extends DrupalWebTestCase { +class NodeTokenReplaceTestCase extends NodeWebTestCase { public static function getInfo() { return array( 'name' => 'Node token replacement', @@ -2306,7 +2329,7 @@ class NodeTokenReplaceTestCase extends DrupalWebTestCase { /** * Tests user permissions for node revisions. */ -class NodeRevisionPermissionsTestCase extends DrupalWebTestCase { +class NodeRevisionPermissionsTestCase extends NodeWebTestCase { protected $node_revisions = array(); protected $accounts = array(); diff --git a/core/modules/openid/openid.test b/core/modules/openid/openid.test index 9d2b3352a6de..7a4c9cf1fe9f 100644 --- a/core/modules/openid/openid.test +++ b/core/modules/openid/openid.test @@ -9,6 +9,37 @@ * Base class for OpenID tests. */ abstract class OpenIDWebTestCase extends DrupalWebTestCase { + function setUp() { + $modules = func_get_args(); + if (isset($modules[0]) && is_array($modules[0])) { + $modules = $modules[0]; + } + $modules[] = 'block'; + $modules[] = 'openid'; + parent::setUp($modules); + + // Enable user login block. + db_merge('block') + ->key(array( + 'module' => 'user', + 'delta' => 'login', + 'theme' => variable_get('theme_default', 'stark'), + )) + ->fields(array( + 'status' => 1, + 'weight' => 0, + 'region' => 'sidebar_first', + 'pages' => '', + 'cache' => -1, + )) + ->execute(); + + // Create Basic page and Article node types. + if ($this->profile != 'standard') { + $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); + $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); + } + } /** * Initiates the login procedure using the specified User-supplied Identity. diff --git a/core/modules/path/path.test b/core/modules/path/path.test index 48af2a4c6e79..32220ee469b9 100644 --- a/core/modules/path/path.test +++ b/core/modules/path/path.test @@ -6,6 +6,24 @@ */ class PathTestCase extends DrupalWebTestCase { + function setUp() { + $modules = func_get_args(); + if (isset($modules[0]) && is_array($modules[0])) { + $modules = $modules[0]; + } + $modules[] = 'node'; + $modules[] = 'path'; + parent::setUp($modules); + + // Create Basic page and Article node types. + if ($this->profile != 'standard') { + $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); + $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); + } + } +} + +class PathAliasTestCase extends PathTestCase { public static function getInfo() { return array( 'name' => 'Path alias functionality', @@ -184,7 +202,7 @@ class PathTestCase extends DrupalWebTestCase { /** * Test URL aliases for taxonomy terms. */ -class PathTaxonomyTermTestCase extends DrupalWebTestCase { +class PathTaxonomyTermTestCase extends PathTestCase { public static function getInfo() { return array( 'name' => 'Taxonomy term URL aliases', @@ -194,7 +212,14 @@ class PathTaxonomyTermTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp('path', 'taxonomy'); + parent::setUp(array('taxonomy')); + + // Create a Tags vocabulary for the Article node type. + $vocabulary = (object) array( + 'name' => t('Tags'), + 'machine_name' => 'tags', + ); + taxonomy_vocabulary_save($vocabulary); // Create and login user. $web_user = $this->drupalCreateUser(array('administer url aliases', 'administer taxonomy', 'access administration pages')); @@ -245,7 +270,7 @@ class PathTaxonomyTermTestCase extends DrupalWebTestCase { } } -class PathLanguageTestCase extends DrupalWebTestCase { +class PathLanguageTestCase extends PathTestCase { public static function getInfo() { return array( 'name' => 'Path aliases with translated nodes', @@ -388,7 +413,7 @@ class PathLanguageTestCase extends DrupalWebTestCase { /** * Tests the user interface for creating path aliases, with languages. */ -class PathLanguageUITestCase extends DrupalWebTestCase { +class PathLanguageUITestCase extends PathTestCase { public static function getInfo() { return array( 'name' => 'Path aliases with languages', @@ -464,7 +489,7 @@ class PathLanguageUITestCase extends DrupalWebTestCase { /** * Tests that paths are not prefixed on a monolingual site. */ -class PathMonolingualTestCase extends DrupalWebTestCase { +class PathMonolingualTestCase extends PathTestCase { public static function getInfo() { return array( 'name' => 'Paths on non-English monolingual sites', diff --git a/core/modules/php/php.test b/core/modules/php/php.test index 7e830820518e..f6009c7e1c83 100644 --- a/core/modules/php/php.test +++ b/core/modules/php/php.test @@ -14,6 +14,9 @@ class PHPTestCase extends DrupalWebTestCase { function setUp() { parent::setUp('php'); + // Create Basic page node type. + $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); + // Create and login admin user. $admin_user = $this->drupalCreateUser(array('administer filters')); $this->drupalLogin($admin_user); @@ -73,7 +76,7 @@ class PHPFilterTestCase extends PHPTestCase { // Make sure that the PHP code shows up as text. $this->drupalGet('node/' . $node->nid); - $this->assertText('print "SimpleTest PHP was executed!"', t('PHP code is displayed.')); + $this->assertText('php print'); // Change filter to PHP filter and see that PHP code is evaluated. $edit = array(); diff --git a/core/modules/poll/poll.test b/core/modules/poll/poll.test index f8ca7fdafc56..ace8d56ca6f6 100644 --- a/core/modules/poll/poll.test +++ b/core/modules/poll/poll.test @@ -5,7 +5,16 @@ * Tests for poll.module. */ -class PollTestCase extends DrupalWebTestCase { +class PollWebTestCase extends DrupalWebTestCase { + function setUp() { + $modules = func_get_args(); + if (isset($modules[0]) && is_array($modules[0])) { + $modules = $modules[0]; + } + $modules[] = 'node'; + $modules[] = 'poll'; + parent::setUp($modules); + } /** * Creates a poll. @@ -76,7 +85,7 @@ class PollTestCase extends DrupalWebTestCase { * The title for the poll node. * @param $choices * An array containing poll choices, as generated by - * PollTestCase::_generateChoices(). + * PollWebTestCase::_generateChoices(). * @param $index * (optional) The amount/number of already submitted poll choices. Defaults * to 0. @@ -120,14 +129,14 @@ class PollTestCase extends DrupalWebTestCase { * * @param $choices * An array containing poll choices, as generated by - * PollTestCase::_generateChoices(). + * PollWebTestCase::_generateChoices(). * @param $index * (optional) The amount/number of already submitted poll choices. Defaults * to 0. * @param $preview * (optional) Whether to also check the poll preview. * - * @see PollTestCase::_pollGenerateEdit() + * @see PollWebTestCase::_pollGenerateEdit() */ function assertPollChoiceOrder(array $choices, $index = 0, $preview = FALSE) { $expected = array(); @@ -181,7 +190,7 @@ class PollTestCase extends DrupalWebTestCase { } } -class PollCreateTestCase extends PollTestCase { +class PollCreateTestCase extends PollWebTestCase { public static function getInfo() { return array( 'name' => 'Poll create', @@ -190,10 +199,6 @@ class PollCreateTestCase extends PollTestCase { ); } - function setUp() { - parent::setUp('poll'); - } - function testPollCreate() { $title = $this->randomName(); $choices = $this->_generateChoices(7); @@ -228,10 +233,10 @@ class PollCreateTestCase extends PollTestCase { $this->clickLink($title); $this->assertText($new_option, 'New option found.'); - $option = $this->xpath('//div[@id="node-1"]//article[@class="poll"]//dt[@class="choice-title"]'); + $option = $this->xpath('//article[@id="node-1"]//article[@class="poll"]//dt[@class="choice-title"]'); $this->assertEqual(end($option), $new_option, 'Last item is equal to new option.'); - $votes = $this->xpath('//div[@id="node-1"]//article[@class="poll"]//div[@class="percent"]'); + $votes = $this->xpath('//article[@id="node-1"]//article[@class="poll"]//div[@class="percent"]'); $this->assertTrue(strpos(end($votes), $vote_count) > 0, t("Votes saved.")); } @@ -287,7 +292,7 @@ class PollCreateTestCase extends PollTestCase { } } -class PollVoteTestCase extends PollTestCase { +class PollVoteTestCase extends PollWebTestCase { public static function getInfo() { return array( 'name' => 'Poll vote', @@ -296,10 +301,6 @@ class PollVoteTestCase extends PollTestCase { ); } - function setUp() { - parent::setUp('poll'); - } - function tearDown() { parent::tearDown(); } @@ -363,7 +364,7 @@ class PollVoteTestCase extends PollTestCase { } } -class PollBlockTestCase extends PollTestCase { +class PollBlockTestCase extends PollWebTestCase { public static function getInfo() { return array( 'name' => 'Block availability', @@ -373,7 +374,7 @@ class PollBlockTestCase extends PollTestCase { } function setUp() { - parent::setUp('poll'); + parent::setUp(array('block')); // Create and login user $admin_user = $this->drupalCreateUser(array('administer blocks')); @@ -444,7 +445,7 @@ class PollJSAddChoice extends DrupalWebTestCase { } function setUp() { - parent::setUp('poll'); + parent::setUp(array('poll')); } /** @@ -471,7 +472,7 @@ class PollJSAddChoice extends DrupalWebTestCase { } } -class PollVoteCheckHostname extends PollTestCase { +class PollVoteCheckHostname extends PollWebTestCase { public static function getInfo() { return array( 'name' => 'User poll vote capability.', @@ -481,7 +482,7 @@ class PollVoteCheckHostname extends PollTestCase { } function setUp() { - parent::setUp('poll'); + parent::setUp(); // Create and login user. $this->admin_user = $this->drupalCreateUser(array('administer permissions', 'create poll content')); @@ -616,7 +617,7 @@ class PollVoteCheckHostname extends PollTestCase { /** * Test poll token replacement in strings. */ -class PollTokenReplaceTestCase extends PollTestCase { +class PollTokenReplaceTestCase extends PollWebTestCase { public static function getInfo() { return array( 'name' => 'Poll token replacement', @@ -625,10 +626,6 @@ class PollTokenReplaceTestCase extends PollTestCase { ); } - function setUp() { - parent::setUp('poll'); - } - /** * Creates a poll, then tests the tokens generated from it. */ @@ -702,7 +699,7 @@ class PollTokenReplaceTestCase extends PollTestCase { } } -class PollExpirationTestCase extends PollTestCase { +class PollExpirationTestCase extends PollWebTestCase { public static function getInfo() { return array( 'name' => 'Poll expiration', @@ -711,10 +708,6 @@ class PollExpirationTestCase extends PollTestCase { ); } - function setUp() { - parent::setUp('poll'); - } - function testAutoExpire() { // Set up a poll. $title = $this->randomName(); @@ -765,7 +758,7 @@ class PollExpirationTestCase extends PollTestCase { } } -class PollDeleteChoiceTestCase extends PollTestCase { +class PollDeleteChoiceTestCase extends PollWebTestCase { public static function getInfo() { return array( 'name' => 'Poll choice deletion', @@ -774,10 +767,6 @@ class PollDeleteChoiceTestCase extends PollTestCase { ); } - function setUp() { - parent::setUp('poll'); - } - function testChoiceRemoval() { // Set up a poll with three choices. $title = $this->randomName(); @@ -804,7 +793,7 @@ class PollDeleteChoiceTestCase extends PollTestCase { /** * Tests poll translation logic. */ -class PollTranslateTestCase extends PollTestCase { +class PollTranslateTestCase extends PollWebTestCase { public static function getInfo() { return array( 'name' => 'Poll translation', @@ -814,7 +803,7 @@ class PollTranslateTestCase extends PollTestCase { } function setUp() { - parent::setUp('poll', 'translation'); + parent::setUp(array('translation')); } /** diff --git a/core/modules/rdf/rdf.test b/core/modules/rdf/rdf.test index 7379f517beda..6c7635fb02ea 100644 --- a/core/modules/rdf/rdf.test +++ b/core/modules/rdf/rdf.test @@ -42,6 +42,8 @@ class RdfMappingHookTestCase extends DrupalWebTestCase { * Test RDFa markup generation. */ class RdfRdfaMarkupTestCase extends DrupalWebTestCase { + protected $profile = 'standard'; + public static function getInfo() { return array( 'name' => 'RDFa markup', @@ -277,6 +279,8 @@ class RdfCrudTestCase extends DrupalWebTestCase { } class RdfMappingDefinitionTestCase extends TaxonomyWebTestCase { + protected $profile = 'standard'; + public static function getInfo() { return array( 'name' => 'RDF mapping definition functionality', @@ -573,6 +577,8 @@ class RdfCommentAttributesTestCase extends CommentHelperCase { } class RdfTrackerAttributesTestCase extends DrupalWebTestCase { + protected $profile = 'standard'; + public static function getInfo() { return array( 'name' => 'RDF tracker page mapping', diff --git a/core/modules/search/search.test b/core/modules/search/search.test index 78516781c8e6..376c8e1b242e 100644 --- a/core/modules/search/search.test +++ b/core/modules/search/search.test @@ -11,7 +11,26 @@ const SEARCH_TYPE = '_test_'; const SEARCH_TYPE_2 = '_test2_'; const SEARCH_TYPE_JPN = '_test3_'; -class SearchMatchTestCase extends DrupalWebTestCase { +class SearchWebTestCase extends DrupalWebTestCase { + function setUp() { + $modules = func_get_args(); + if (isset($modules[0]) && is_array($modules[0])) { + $modules = $modules[0]; + } + $modules[] = 'node'; + $modules[] = 'search'; + $modules[] = 'dblog'; + parent::setUp($modules); + + // Create Basic page and Article node types. + if ($this->profile != 'standard') { + $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); + $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); + } + } +} + +class SearchMatchTestCase extends SearchWebTestCase { public static function getInfo() { return array( 'name' => 'Search engine queries', @@ -20,13 +39,6 @@ class SearchMatchTestCase extends DrupalWebTestCase { ); } - /** - * Implementation setUp(). - */ - function setUp() { - parent::setUp('search'); - } - /** * Test search indexing. */ @@ -243,7 +255,7 @@ class SearchMatchTestCase extends DrupalWebTestCase { /** * Tests the bike shed text on no results page, and text on the search page. */ -class SearchPageText extends DrupalWebTestCase { +class SearchPageText extends SearchWebTestCase { protected $searching_user; public static function getInfo() { @@ -255,7 +267,7 @@ class SearchPageText extends DrupalWebTestCase { } function setUp() { - parent::setUp('search'); + parent::setUp(); // Create user. $this->searching_user = $this->drupalCreateUser(array('search content', 'access user profiles')); @@ -307,7 +319,7 @@ class SearchPageText extends DrupalWebTestCase { } } -class SearchAdvancedSearchForm extends DrupalWebTestCase { +class SearchAdvancedSearchForm extends SearchWebTestCase { protected $node; public static function getInfo() { @@ -319,7 +331,7 @@ class SearchAdvancedSearchForm extends DrupalWebTestCase { } function setUp() { - parent::setUp('search'); + parent::setUp(); // Create and login user. $test_user = $this->drupalCreateUser(array('access content', 'search content', 'use advanced search', 'administer nodes')); $this->drupalLogin($test_user); @@ -370,7 +382,7 @@ class SearchAdvancedSearchForm extends DrupalWebTestCase { } } -class SearchRankingTestCase extends DrupalWebTestCase { +class SearchRankingTestCase extends SearchWebTestCase { public static function getInfo() { return array( 'name' => 'Search engine ranking', @@ -379,16 +391,13 @@ class SearchRankingTestCase extends DrupalWebTestCase { ); } - /** - * Implementation setUp(). - */ function setUp() { - parent::setUp('search', 'statistics', 'comment'); + parent::setUp(array('statistics', 'comment')); } function testRankings() { // Login with sufficient privileges. - $this->drupalLogin($this->drupalCreateUser(array('skip comment approval', 'create page content'))); + $this->drupalLogin($this->drupalCreateUser(array('post comments', 'skip comment approval', 'create page content'))); // Build a list of the rankings to test. $node_ranks = array('sticky', 'promote', 'relevance', 'recent', 'comments', 'views'); @@ -462,6 +471,13 @@ class SearchRankingTestCase extends DrupalWebTestCase { * Test rankings of HTML tags. */ function testHTMLRankings() { + $full_html_format = array( + 'format' => 'full_html', + 'name' => 'Full HTML', + ); + $full_html_format = (object) $full_html_format; + filter_format_save($full_html_format); + // Login with sufficient privileges. $this->drupalLogin($this->drupalCreateUser(array('create page content'))); @@ -580,7 +596,7 @@ class SearchRankingTestCase extends DrupalWebTestCase { } } -class SearchBlockTestCase extends DrupalWebTestCase { +class SearchBlockTestCase extends SearchWebTestCase { public static function getInfo() { return array( 'name' => 'Block availability', @@ -590,7 +606,7 @@ class SearchBlockTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp('search'); + parent::setUp(array('block')); // Create and login user $admin_user = $this->drupalCreateUser(array('administer blocks', 'search content')); @@ -660,7 +676,7 @@ class SearchBlockTestCase extends DrupalWebTestCase { /** * Tests that searching for a phrase gets the correct page count. */ -class SearchExactTestCase extends DrupalWebTestCase { +class SearchExactTestCase extends SearchWebTestCase { public static function getInfo() { return array( 'name' => 'Search engine phrase queries', @@ -669,10 +685,6 @@ class SearchExactTestCase extends DrupalWebTestCase { ); } - function setUp() { - parent::setUp('search'); - } - /** * Tests that the correct number of pager links are found for both keywords and phrases. */ @@ -721,7 +733,9 @@ class SearchExactTestCase extends DrupalWebTestCase { /** * Test integration searching comments. */ -class SearchCommentTestCase extends DrupalWebTestCase { +class SearchCommentTestCase extends SearchWebTestCase { + protected $profile = 'standard'; + protected $admin_user; public static function getInfo() { @@ -733,7 +747,7 @@ class SearchCommentTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp('comment', 'search'); + parent::setUp(array('comment')); // Create and log in an administrative user having access to the Full HTML // text format. @@ -1017,7 +1031,10 @@ class SearchExpressionInsertExtractTestCase extends DrupalUnitTestCase { * only when there are comments * - Nodes with comment status set to Hidden should never show comment counts */ -class SearchCommentCountToggleTestCase extends DrupalWebTestCase { +class SearchCommentCountToggleTestCase extends SearchWebTestCase { + // Requires node types, comment config, filter formats. + protected $profile = 'standard'; + protected $searching_user; protected $searchable_nodes; @@ -1030,7 +1047,7 @@ class SearchCommentCountToggleTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp('search'); + parent::setUp(array('comment')); // Create searching user. $this->searching_user = $this->drupalCreateUser(array('search content', 'access content', 'access comments', 'skip comment approval')); @@ -1102,7 +1119,7 @@ class SearchCommentCountToggleTestCase extends DrupalWebTestCase { /** * Test search_simplify() on every Unicode character, and some other cases. */ -class SearchSimplifyTestCase extends DrupalWebTestCase { +class SearchSimplifyTestCase extends SearchWebTestCase { public static function getInfo() { return array( 'name' => 'Search simplify', @@ -1185,8 +1202,7 @@ class SearchSimplifyTestCase extends DrupalWebTestCase { /** * Tests keywords and conditions. */ -class SearchKeywordsConditions extends DrupalWebTestCase { - +class SearchKeywordsConditions extends SearchWebTestCase { public static function getInfo() { return array( 'name' => 'Keywords and conditions', @@ -1196,7 +1212,7 @@ class SearchKeywordsConditions extends DrupalWebTestCase { } function setUp() { - parent::setUp('search', 'search_extra_type'); + parent::setUp(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. @@ -1236,7 +1252,7 @@ class SearchKeywordsConditions extends DrupalWebTestCase { /** * Tests that numbers can be searched. */ -class SearchNumbersTestCase extends DrupalWebTestCase { +class SearchNumbersTestCase extends SearchWebTestCase { protected $test_user; protected $numbers; protected $nodes; @@ -1250,7 +1266,7 @@ class SearchNumbersTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp('search'); + parent::setUp(); $this->test_user = $this->drupalCreateUser(array('search content', 'access content', 'administer nodes', 'access site reports')); $this->drupalLogin($this->test_user); @@ -1324,7 +1340,7 @@ class SearchNumbersTestCase extends DrupalWebTestCase { /** * Tests that numbers can be searched, with more complex matching. */ -class SearchNumberMatchingTestCase extends DrupalWebTestCase { +class SearchNumberMatchingTestCase extends SearchWebTestCase { protected $test_user; protected $numbers; protected $nodes; @@ -1338,7 +1354,7 @@ class SearchNumberMatchingTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp('search'); + parent::setUp(); $this->test_user = $this->drupalCreateUser(array('search content', 'access content', 'administer nodes', 'access site reports')); $this->drupalLogin($this->test_user); @@ -1407,7 +1423,7 @@ class SearchNumberMatchingTestCase extends DrupalWebTestCase { /** * Test config page. */ -class SearchConfigSettingsForm extends DrupalWebTestCase { +class SearchConfigSettingsForm extends SearchWebTestCase { public $search_user; public $search_node; @@ -1420,7 +1436,7 @@ class SearchConfigSettingsForm extends DrupalWebTestCase { } function setUp() { - parent::setUp('search', 'search_extra_type'); + parent::setUp(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')); @@ -1645,7 +1661,7 @@ class SearchExcerptTestCase extends DrupalUnitTestCase { /** * Test the CJK tokenizer. */ -class SearchTokenizerTestCase extends DrupalWebTestCase { +class SearchTokenizerTestCase extends SearchWebTestCase { public static function getInfo() { return array( 'name' => 'CJK tokenizer', @@ -1654,10 +1670,6 @@ class SearchTokenizerTestCase extends DrupalWebTestCase { ); } - function setUp() { - parent::setUp('search'); - } - /** * Verifies that strings of CJK characters are tokenized. * @@ -1796,7 +1808,7 @@ class SearchTokenizerTestCase extends DrupalWebTestCase { /** * Tests that we can embed a form in search results and submit it. */ -class SearchEmbedForm extends DrupalWebTestCase { +class SearchEmbedForm extends SearchWebTestCase { /** * Node used for testing. */ @@ -1816,7 +1828,7 @@ class SearchEmbedForm extends DrupalWebTestCase { } function setUp() { - parent::setUp('search', 'search_embedded_form'); + parent::setUp(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')); @@ -1872,7 +1884,7 @@ class SearchEmbedForm extends DrupalWebTestCase { /** * Tests that hook_search_page runs. */ -class SearchPageOverride extends DrupalWebTestCase { +class SearchPageOverride extends SearchWebTestCase { public $search_user; public static function getInfo() { @@ -1884,7 +1896,7 @@ class SearchPageOverride extends DrupalWebTestCase { } function setUp() { - parent::setUp('search', 'search_extra_type'); + parent::setUp(array('search_extra_type')); // Login as a user that can create and search content. $this->search_user = $this->drupalCreateUser(array('search content', 'administer search')); @@ -1906,7 +1918,7 @@ class SearchPageOverride extends DrupalWebTestCase { /** * Test node search with multiple languages. */ -class SearchLanguageTestCase extends DrupalWebTestCase { +class SearchLanguageTestCase extends SearchWebTestCase { public static function getInfo() { return array( 'name' => 'Search language selection', @@ -1915,11 +1927,8 @@ class SearchLanguageTestCase extends DrupalWebTestCase { ); } - /** - * Implementation setUp(). - */ function setUp() { - parent::setUp('search', 'locale'); + parent::setUp(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')); @@ -1934,7 +1943,7 @@ class SearchLanguageTestCase extends DrupalWebTestCase { // Add predefined language. $edit = array('predefined_langcode' => 'fr'); $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); - $this->assertText('fr', t('Language added successfully.')); + $this->assertText('French', t('Language added successfully.')); // Now we should have languages displayed. $this->drupalGet('search/node'); @@ -1971,7 +1980,7 @@ class SearchLanguageTestCase extends DrupalWebTestCase { /** * Tests node search with node access control. */ -class SearchNodeAccessTest extends DrupalWebTestCase { +class SearchNodeAccessTest extends SearchWebTestCase { public $test_user; public static function getInfo() { @@ -1983,7 +1992,7 @@ class SearchNodeAccessTest extends DrupalWebTestCase { } function setUp() { - parent::setUp('search', 'node_access_test'); + parent::setUp(array('node_access_test')); node_access_rebuild(); // Create a test user and log in. diff --git a/core/modules/shortcut/shortcut.install b/core/modules/shortcut/shortcut.install index 7aee9c9ca068..60c113aea38a 100644 --- a/core/modules/shortcut/shortcut.install +++ b/core/modules/shortcut/shortcut.install @@ -30,7 +30,12 @@ function shortcut_install() { // set, to make sure the links defined above can be correctly saved. (During // installation, the menu might not have been built at all yet, or it might // have been built but without the node module's links in it.) - if (drupal_installation_attempted()) { + // drupal_installation_attempted() cannot be used here, as it relies on the + // MAINTENANCE_MODE constant value, which cannot be set when running tests, so + // we check the 'install_task' variable instead, which is only "done" when + // Drupal is already installed (i.e., we are not in the installer). + // @see http://drupal.org/node/1376150 + if (variable_get('install_task', '') != 'done') { menu_rebuild(); } shortcut_set_save($shortcut_set); diff --git a/core/modules/shortcut/shortcut.test b/core/modules/shortcut/shortcut.test index 322c63f1119b..550c10cdb559 100644 --- a/core/modules/shortcut/shortcut.test +++ b/core/modules/shortcut/shortcut.test @@ -32,6 +32,13 @@ class ShortcutTestCase extends DrupalWebTestCase { function setUp() { parent::setUp('toolbar', 'shortcut'); + + // Create Basic page and Article node types. + if ($this->profile != 'standard') { + $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); + $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); + } + // Create users. $this->admin_user = $this->drupalCreateUser(array('access toolbar', 'administer shortcuts', 'view the administration theme', 'create article content', 'create page content', 'access content overview')); $this->shortcut_user = $this->drupalCreateUser(array('customize shortcut links', 'switch shortcut sets')); @@ -150,6 +157,9 @@ class ShortcutLinksTestCase extends ShortcutTestCase { * Tests that the "add to shortcut" link changes to "remove shortcut". */ function testShortcutQuickLink() { + theme_enable(array('seven')); + variable_set('admin_theme', 'seven'); + variable_set('node_admin_theme', TRUE); $this->drupalGet($this->set->links[0]['link_path']); $this->assertRaw(t('Remove from %title shortcuts', array('%title' => $this->set->title)), '"Add to shortcuts" link properly switched to "Remove from shortcuts".'); } diff --git a/core/modules/simpletest/drupal_web_test_case.php b/core/modules/simpletest/drupal_web_test_case.php index 4013cf158e92..f31c7077bbd9 100644 --- a/core/modules/simpletest/drupal_web_test_case.php +++ b/core/modules/simpletest/drupal_web_test_case.php @@ -768,7 +768,7 @@ class DrupalWebTestCase extends DrupalTestCase { * * @var string */ - protected $profile = 'standard'; + protected $profile = 'testing'; /** * The URL currently loaded in the internal browser. diff --git a/core/modules/simpletest/simpletest.test b/core/modules/simpletest/simpletest.test index f4bdd132a01e..55a48be95c2f 100644 --- a/core/modules/simpletest/simpletest.test +++ b/core/modules/simpletest/simpletest.test @@ -72,7 +72,9 @@ class SimpleTestFunctionalTest extends DrupalWebTestCase { 'pass' => $user->pass_raw ); variable_set('simpletest_maximum_redirects', 1); - $this->drupalPost('user?destination=user/logout', $edit, t('Log in')); + $this->drupalPost('user', $edit, t('Log in'), array( + 'query' => array('destination' => 'user/logout'), + )); $headers = $this->drupalGetHeaders(TRUE); $this->assertEqual(count($headers), 2, t('Simpletest stopped following redirects after the first one.')); } diff --git a/core/modules/simpletest/tests/ajax.test b/core/modules/simpletest/tests/ajax.test index 014a350421a4..3184add156ca 100644 --- a/core/modules/simpletest/tests/ajax.test +++ b/core/modules/simpletest/tests/ajax.test @@ -58,8 +58,6 @@ class AJAXTestCase extends DrupalWebTestCase { * Tests primary Ajax framework functions. */ class AJAXFrameworkTestCase extends AJAXTestCase { - protected $profile = 'testing'; - public static function getInfo() { return array( 'name' => 'AJAX framework', @@ -426,6 +424,8 @@ class AJAXFormValuesTestCase extends AJAXTestCase { * Tests that Ajax-enabled forms work when multiple instances of the same form are on a page. */ class AJAXMultiFormTestCase extends AJAXTestCase { + protected $profile = 'standard'; + public static function getInfo() { return array( 'name' => 'AJAX multi form', diff --git a/core/modules/simpletest/tests/bootstrap.test b/core/modules/simpletest/tests/bootstrap.test index fee8fcc0dd12..371031a32706 100644 --- a/core/modules/simpletest/tests/bootstrap.test +++ b/core/modules/simpletest/tests/bootstrap.test @@ -109,7 +109,10 @@ class BootstrapPageCacheTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp('system_test'); + parent::setUp(array('node', 'system_test')); + + variable_set('site_name', 'Drupal'); + variable_set('site_frontpage', 'node'); } /** diff --git a/core/modules/simpletest/tests/common.test b/core/modules/simpletest/tests/common.test index 5cb238f2c0f3..4f20361d9445 100644 --- a/core/modules/simpletest/tests/common.test +++ b/core/modules/simpletest/tests/common.test @@ -18,7 +18,7 @@ class CommonDrupalAlterTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp('common_test'); + parent::setUp(array('block', 'common_test')); } function testDrupalAlter() { @@ -594,7 +594,7 @@ class CommonCascadingStylesheetsTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp('php', 'language', 'common_test'); + parent::setUp(array('language', 'common_test')); // Reset drupal_add_css() before each test. drupal_static_reset('drupal_add_css'); } @@ -700,11 +700,16 @@ class CommonCascadingStylesheetsTestCase extends DrupalWebTestCase { * Tests rendering inline stylesheets through a full page request. */ function testRenderInlineFullPage() { + module_enable(array('php')); + $css = 'body { font-size: 254px; }'; // Inline CSS is minified unless 'preprocess' => FALSE is passed as a // drupal_add_css() option. $expected = 'body{font-size:254px;}'; + // Create Basic page node type. + $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); + // Create a node, using the PHP filter that tests drupal_add_css(). $php_format_id = 'php_code'; $settings = array( @@ -2255,11 +2260,6 @@ class CommonDrupalParseInfoFileTestCase extends DrupalUnitTestCase { * Tests scanning system directories in drupal_system_listing(). */ class CommonDrupalSystemListingTestCase extends DrupalWebTestCase { - /** - * Use the testing profile; this is needed for testDirectoryPrecedence(). - */ - protected $profile = 'testing'; - public static function getInfo() { return array( 'name' => 'Drupal system listing', diff --git a/core/modules/simpletest/tests/database_test.test b/core/modules/simpletest/tests/database_test.test index 1d38ebb3766b..487953ed1982 100644 --- a/core/modules/simpletest/tests/database_test.test +++ b/core/modules/simpletest/tests/database_test.test @@ -25,8 +25,6 @@ class FakeRecord { } * here. */ class DatabaseTestCase extends DrupalWebTestCase { - protected $profile = 'testing'; - function setUp() { $modules = func_get_args(); if (isset($modules[0]) && is_array($modules[0])) { diff --git a/core/modules/simpletest/tests/file.test b/core/modules/simpletest/tests/file.test index ecc04f8b4cd7..5b6a6f456aec 100644 --- a/core/modules/simpletest/tests/file.test +++ b/core/modules/simpletest/tests/file.test @@ -47,6 +47,20 @@ function file_test_file_scan_callback_reset() { * assertions and helper functions. */ class FileTestCase extends DrupalWebTestCase { + + function setUp() { + $modules = func_get_args(); + $modules = (isset($modules[0]) && is_array($modules[0]) ? $modules[0] : $modules); + parent::setUp($modules); + + // Make sure that custom stream wrappers are registered. + // @todo This has the potential to be a major bug deeply buried in File API; + // file_unmanaged_*() API functions and test functions are invoking native + // PHP functions directly, whereas Drupal's custom stream wrappers are not + // registered yet. + file_get_stream_wrappers(); + } + /** * Check that two files have the same values for all fields other than the * timestamp. diff --git a/core/modules/simpletest/tests/form.test b/core/modules/simpletest/tests/form.test index 3d61911e73b3..394637401092 100644 --- a/core/modules/simpletest/tests/form.test +++ b/core/modules/simpletest/tests/form.test @@ -16,7 +16,17 @@ class FormsTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp('form_test'); + parent::setUp(array('form_test', 'file')); + + $filtered_html_format = array( + 'format' => 'filtered_html', + 'name' => 'Filtered HTML', + ); + $filtered_html_format = (object) $filtered_html_format; + filter_format_save($filtered_html_format); + + $filtered_html_permission = filter_permission_name($filtered_html_format); + user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array($filtered_html_permission)); } /** @@ -444,8 +454,6 @@ class FormsTestCase extends DrupalWebTestCase { * Tests building and processing of core form elements. */ class FormElementTestCase extends DrupalWebTestCase { - protected $profile = 'testing'; - public static function getInfo() { return array( 'name' => 'Element processing', @@ -536,7 +544,7 @@ class FormAlterTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp('form_test'); + parent::setUp(array('block', 'form_test')); } /** @@ -1208,7 +1216,7 @@ class FormStateValuesCleanAdvancedTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp('form_test'); + parent::setUp(array('file', 'form_test')); } /** @@ -1252,6 +1260,8 @@ class FormsRebuildTestCase extends DrupalWebTestCase { function setUp() { parent::setUp('form_test'); + $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); + $this->web_user = $this->drupalCreateUser(array('access content')); $this->drupalLogin($this->web_user); } diff --git a/core/modules/simpletest/tests/form_test.module b/core/modules/simpletest/tests/form_test.module index 58625666f5c5..4b0f29547266 100644 --- a/core/modules/simpletest/tests/form_test.module +++ b/core/modules/simpletest/tests/form_test.module @@ -13,14 +13,14 @@ function form_test_menu() { 'title' => 'Form altering test', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_test_alter_form'), - 'access arguments' => array('access content'), + 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); $items['form-test/validate'] = array( 'title' => 'Form validation handlers test', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_test_validate_form'), - 'access arguments' => array('access content'), + 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); $items['form-test/validate-required'] = array( @@ -34,7 +34,7 @@ function form_test_menu() { 'title' => 'Form validation with some error suppression', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_test_limit_validation_errors_form'), - 'access arguments' => array('access content'), + 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); @@ -42,28 +42,28 @@ function form_test_menu() { 'title' => 'Tableselect checkboxes test', 'page callback' => 'drupal_get_form', 'page arguments' => array('_form_test_tableselect_multiple_true_form'), - 'access arguments' => array('access content'), + 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); $items['form_test/tableselect/multiple-false'] = array( 'title' => 'Tableselect radio button test', 'page callback' => 'drupal_get_form', 'page arguments' => array('_form_test_tableselect_multiple_false_form'), - 'access arguments' => array('access content'), + 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); $items['form_test/tableselect/empty-text'] = array( 'title' => 'Tableselect empty text test', 'page callback' => 'drupal_get_form', 'page arguments' => array('_form_test_tableselect_empty_form'), - 'access arguments' => array('access content'), + 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); $items['form_test/tableselect/advanced-select'] = array( 'title' => 'Tableselect js_select tests', 'page callback' => 'drupal_get_form', 'page arguments' => array('_form_test_tableselect_js_select_form'), - 'access arguments' => array('access content'), + 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); @@ -71,7 +71,7 @@ function form_test_menu() { 'title' => 'Vertical tabs tests', 'page callback' => 'drupal_get_form', 'page arguments' => array('_form_test_vertical_tabs_form'), - 'access arguments' => array('access content'), + 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); @@ -79,7 +79,7 @@ function form_test_menu() { 'title' => 'Form storage test', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_test_storage_form'), - 'access arguments' => array('access content'), + 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); @@ -87,7 +87,7 @@ function form_test_menu() { 'title' => 'Form wrapper callback test', 'page callback' => 'form_test_wrapper_callback', 'page arguments' => array('form_test_wrapper_callback_form'), - 'access arguments' => array('access content'), + 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); @@ -95,7 +95,7 @@ function form_test_menu() { 'title' => 'Form state values clearance test', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_test_form_state_values_clean_form'), - 'access arguments' => array('access content'), + 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); @@ -103,7 +103,7 @@ function form_test_menu() { 'title' => 'Form state values clearance advanced test', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_test_form_state_values_clean_advanced_form'), - 'access arguments' => array('access content'), + 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); @@ -165,7 +165,7 @@ function form_test_menu() { 'title' => 'Form values preservation during rebuild test', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_test_form_rebuild_preserve_values_form'), - 'access arguments' => array('access content'), + 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); @@ -173,7 +173,7 @@ function form_test_menu() { 'title' => 'Form label test', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_label_test_form'), - 'access arguments' => array('access content'), + 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); diff --git a/core/modules/simpletest/tests/image.test b/core/modules/simpletest/tests/image.test index ab008e55f281..deead570a084 100644 --- a/core/modules/simpletest/tests/image.test +++ b/core/modules/simpletest/tests/image.test @@ -465,8 +465,12 @@ class ImageToolkitGdTestCase extends DrupalWebTestCase { /** * Tests the file move function for managed files. + * + * @todo This test belongs to File module. */ class ImageFileMoveTest extends ImageToolkitTestCase { + protected $profile = 'standard'; + public static function getInfo() { return array( 'name' => 'Image moving', diff --git a/core/modules/simpletest/tests/menu.test b/core/modules/simpletest/tests/menu.test index afec3b083a22..41379ad4aed4 100644 --- a/core/modules/simpletest/tests/menu.test +++ b/core/modules/simpletest/tests/menu.test @@ -132,12 +132,30 @@ class MenuRouterTestCase extends DrupalWebTestCase { function setUp() { // Enable dummy module that implements hook_menu. - parent::setUp('menu_test'); + parent::setUp(array('block', 'menu_test')); + // Make the tests below more robust by explicitly setting the default theme // and administrative theme that they expect. theme_enable(array('bartik')); variable_set('theme_default', 'bartik'); variable_set('admin_theme', 'seven'); + theme_disable(array('stark')); + + // Enable navigation menu block. + db_merge('block') + ->key(array( + 'module' => 'system', + 'delta' => 'navigation', + 'theme' => 'bartik', + )) + ->fields(array( + 'status' => 1, + 'weight' => 0, + 'region' => 'sidebar_first', + 'pages' => '', + 'cache' => -1, + )) + ->execute(); } /** @@ -239,15 +257,15 @@ class MenuRouterTestCase extends DrupalWebTestCase { * 'user' and 'user/register' gets redirected to the user edit page. */ function testAuthUserUserLogin() { - $loggedInUser = $this->drupalCreateUser(array()); - $this->drupalLogin($loggedInUser); + $this->loggedInUser = $this->drupalCreateUser(array()); + $this->drupalLogin($this->loggedInUser); - $this->DrupalGet('user/login'); + $this->drupalGet('user/login'); // Check that we got to 'user'. $this->assertTrue($this->url == url('user', array('absolute' => TRUE)), t("Logged-in user redirected to q=user on accessing q=user/login")); // user/register should redirect to user/UID/edit. - $this->DrupalGet('user/register'); + $this->drupalGet('user/register'); $this->assertTrue($this->url == url('user/' . $this->loggedInUser->uid . '/edit', array('absolute' => TRUE)), t("Logged-in user redirected to q=user/UID/edit on accessing q=user/register")); } @@ -321,46 +339,46 @@ class MenuRouterTestCase extends DrupalWebTestCase { * Tests for menu_link_maintain(). */ function testMenuLinkMaintain() { - $admin_user = $this->drupalCreateUser(array('administer site configuration')); + $admin_user = $this->drupalCreateUser(array('access content', 'administer site configuration')); $this->drupalLogin($admin_user); // Create three menu items. menu_link_maintain('menu_test', 'insert', 'menu_test_maintain/1', 'Menu link #1'); - menu_link_maintain('menu_test', 'insert', 'menu_test_maintain/1', 'Menu link #1-1'); + menu_link_maintain('menu_test', 'insert', 'menu_test_maintain/1', 'Menu link #1-main'); menu_link_maintain('menu_test', 'insert', 'menu_test_maintain/2', 'Menu link #2'); // Move second link to the main-menu, to test caching later on. db_update('menu_links') ->fields(array('menu_name' => 'main-menu')) - ->condition('link_title', 'Menu link #1-1') + ->condition('link_title', 'Menu link #1-main') ->condition('customized', 0) ->condition('module', 'menu_test') ->execute(); - menu_cache_clear('main-menu'); + menu_cache_clear_all(); // Load front page. - $this->drupalGet('node'); - $this->assertLink(t('Menu link #1'), 0, 'Found menu link #1'); - $this->assertLink(t('Menu link #1-1'), 0, 'Found menu link #1-1'); - $this->assertLink(t('Menu link #2'), 0, 'Found menu link #2'); + $this->drupalGet(''); + $this->assertLink('Menu link #1'); + $this->assertLink('Menu link #1-main'); + $this->assertLink('Menu link #2'); // Rename all links for the given path. menu_link_maintain('menu_test', 'update', 'menu_test_maintain/1', 'Menu link updated'); // Load a different page to be sure that we have up to date information. $this->drupalGet('menu_test_maintain/1'); - $this->assertLink(t('Menu link updated'), 0, t('Found updated menu link')); - $this->assertNoLink(t('Menu link #1'), 0, t('Not found menu link #1')); - $this->assertNoLink(t('Menu link #1'), 0, t('Not found menu link #1-1')); - $this->assertLink(t('Menu link #2'), 0, t('Found menu link #2')); + $this->assertLink('Menu link updated'); + $this->assertNoLink('Menu link #1'); + $this->assertNoLink('Menu link #1-main'); + $this->assertLink('Menu link #2'); // Delete all links for the given path. menu_link_maintain('menu_test', 'delete', 'menu_test_maintain/1', ''); // Load a different page to be sure that we have up to date information. $this->drupalGet('menu_test_maintain/2'); - $this->assertNoLink(t('Menu link updated'), 0, t('Not found deleted menu link')); - $this->assertNoLink(t('Menu link #1'), 0, t('Not found menu link #1')); - $this->assertNoLink(t('Menu link #1'), 0, t('Not found menu link #1-1')); - $this->assertLink(t('Menu link #2'), 0, t('Found menu link #2')); + $this->assertNoLink('Menu link updated'); + $this->assertNoLink('Menu link #1'); + $this->assertNoLink('Menu link #1-main'); + $this->assertLink('Menu link #2'); } /** @@ -647,9 +665,6 @@ class MenuRouterTestCase extends DrupalWebTestCase { * Tests for menu links. */ class MenuLinksUnitTestCase extends DrupalWebTestCase { - // Use the lightweight testing profile for this test. - protected $profile = 'testing'; - public static function getInfo() { return array( 'name' => 'Menu links', @@ -1017,6 +1032,8 @@ class MenuTreeOutputTestCase extends DrupalWebTestCase { * Menu breadcrumbs related tests. */ class MenuBreadcrumbTestCase extends MenuWebTestCase { + protected $profile = 'standard'; + public static function getInfo() { return array( 'name' => 'Breadcrumbs', @@ -1026,12 +1043,8 @@ class MenuBreadcrumbTestCase extends MenuWebTestCase { } function setUp() { - $modules = func_get_args(); - if (isset($modules[0]) && is_array($modules[0])) { - $modules = $modules[0]; - } - $modules[] = 'menu_test'; - parent::setUp($modules); + parent::setUp(array('menu_test')); + $perms = array_keys(module_invoke_all('permission')); $this->admin_user = $this->drupalCreateUser($perms); $this->drupalLogin($this->admin_user); @@ -1520,12 +1533,7 @@ class MenuTrailTestCase extends MenuWebTestCase { } function setUp() { - $modules = func_get_args(); - if (isset($modules[0]) && is_array($modules[0])) { - $modules = $modules[0]; - } - $modules[] = 'menu_test'; - parent::setUp($modules); + parent::setUp(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/simpletest/tests/module.test b/core/modules/simpletest/tests/module.test index c9601c9b9ab7..3fc5d40c3937 100644 --- a/core/modules/simpletest/tests/module.test +++ b/core/modules/simpletest/tests/module.test @@ -9,6 +9,9 @@ * Unit tests for the module API. */ class ModuleUnitTest extends DrupalWebTestCase { + // Requires Standard profile modules/dependencies. + protected $profile = 'standard'; + public static function getInfo() { return array( 'name' => 'Module API', diff --git a/core/modules/simpletest/tests/password.test b/core/modules/simpletest/tests/password.test index e0139e992102..2797786d9890 100644 --- a/core/modules/simpletest/tests/password.test +++ b/core/modules/simpletest/tests/password.test @@ -9,8 +9,6 @@ * Unit tests for password hashing API. */ class PasswordHashingTest extends DrupalWebTestCase { - protected $profile = 'testing'; - public static function getInfo() { return array( 'name' => 'Password hashing', diff --git a/core/modules/simpletest/tests/theme.test b/core/modules/simpletest/tests/theme.test index a795054c5d6b..1550a80690e0 100644 --- a/core/modules/simpletest/tests/theme.test +++ b/core/modules/simpletest/tests/theme.test @@ -9,8 +9,6 @@ * Unit tests for the Theme API. */ class ThemeUnitTest extends DrupalWebTestCase { - protected $profile = 'testing'; - public static function getInfo() { return array( 'name' => 'Theme API', @@ -222,8 +220,6 @@ class ThemeTableUnitTest extends DrupalWebTestCase { * Tests for common theme functions. */ class ThemeFunctionsTestCase extends DrupalWebTestCase { - protected $profile = 'testing'; - public static function getInfo() { return array( 'name' => 'Theme functions', @@ -499,8 +495,11 @@ class ThemeHookInitUnitTest extends DrupalWebTestCase { */ function testThemeInitializationHookInit() { $this->drupalGet('theme-test/hook-init'); - $this->assertRaw('Themed output generated in hook_init()', t('Themed output generated in hook_init() correctly appears on the page.')); - $this->assertRaw('bartik/css/style.css', t("The default theme's CSS appears on the page when the theme system is initialized in hook_init().")); + // Verify that themed output generated in hook_init() appears. + $this->assertRaw('Themed output generated in hook_init()'); + // Verify that the default theme's CSS still appears when the theme system + // is initialized in hook_init(). + $this->assertRaw('stark/layout.css'); } } diff --git a/core/modules/statistics/statistics.test b/core/modules/statistics/statistics.test index bf3aeac4cb20..62cec24dbd99 100644 --- a/core/modules/statistics/statistics.test +++ b/core/modules/statistics/statistics.test @@ -11,7 +11,12 @@ class StatisticsTestCase extends DrupalWebTestCase { function setUp() { - parent::setUp('statistics'); + parent::setUp(array('node', 'block', 'statistics')); + + // Create Basic page node type. + if ($this->profile != 'standard') { + $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); + } // Create user. $this->blocking_user = $this->drupalCreateUser(array( @@ -61,7 +66,12 @@ class StatisticsLoggingTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp('statistics'); + parent::setUp(array('statistics', 'block')); + + // Create Basic page node type. + if ($this->profile != 'standard') { + $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); + } $this->auth_user = $this->drupalCreateUser(array('access content', 'create page content', 'edit own page content')); @@ -299,7 +309,12 @@ class StatisticsAdminTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp('statistics'); + parent::setUp(array('node', 'statistics')); + + // Create Basic page node type. + if ($this->profile != 'standard') { + $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); + } $this->privileged_user = $this->drupalCreateUser(array('access statistics', 'administer statistics', 'view post access counter', 'create page content')); $this->drupalLogin($this->privileged_user); $this->test_node = $this->drupalCreateNode(array('type' => 'page', 'uid' => $this->privileged_user->uid)); @@ -382,7 +397,11 @@ class StatisticsAdminTestCase extends DrupalWebTestCase { $timestamp = time(); $this->drupalPost(NULL, NULL, t('Cancel account')); // Confirm account cancellation request. - $this->drupalGet("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login)); + $mails = $this->drupalGetMails(); + $mail = end($mails); + preg_match('@http.+?(user/\d+/cancel/confirm/\d+/[^\s]+)@', $mail['body'], $matches); + $path = $matches[1]; + $this->drupalGet($path); $this->assertFalse(user_load($account->uid, TRUE), t('User is not found in the database.')); $this->drupalGet('admin/reports/visitors'); diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 469f996655d0..07eacd28866d 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -2392,7 +2392,6 @@ function _system_rebuild_module_data() { $modules[$profile] = new stdClass(); $modules[$profile]->name = $profile; $modules[$profile]->uri = 'profiles/' . $profile . '/' . $profile . '.profile'; - $modules[$profile]->filename = $profile . '.profile'; // Install profile hooks are always executed last. $modules[$profile]->weight = 1000; diff --git a/core/modules/system/system.test b/core/modules/system/system.test index 3b958dd35505..9287d16d8a01 100644 --- a/core/modules/system/system.test +++ b/core/modules/system/system.test @@ -132,8 +132,6 @@ class ModuleTestCase extends DrupalWebTestCase { * Test module enabling/disabling functionality. */ class EnableDisableTestCase extends ModuleTestCase { - protected $profile = 'testing'; - public static function getInfo() { return array( 'name' => 'Enable/disable modules', @@ -154,7 +152,26 @@ class EnableDisableTestCase extends ModuleTestCase { unset($modules[$name]); } } - $this->assertTrue(count($modules), t('Found @count core modules that we can try to enable in this test.', array('@count' => count($modules)))); + + // Throughout this test, some modules may be automatically enabled (due to + // dependencies). We'll keep track of them in an array, so we can handle + // them separately. + $automatically_enabled = array(); + + // Remove already enabled modules (via installation profile). + // @todo Remove this after removing all dependencies from Testing profile. + foreach (module_list() as $dependency) { + // Exclude required modules. Only installation profile "suggestions" can + // be disabled and uninstalled. + if (isset($modules[$dependency])) { + $automatically_enabled[$dependency] = TRUE; + } + } + + $this->assertTrue(count($modules), t('Found @count modules that can be enabled: %modules', array( + '@count' => count($modules), + '%modules' => implode(', ', array_keys($modules)), + ))); // Enable the dblog module first, since we will be asserting the presence // of log messages throughout the test. @@ -166,11 +183,6 @@ class EnableDisableTestCase extends ModuleTestCase { // will display messages via drupal_set_message(). variable_set('test_verbose_module_hooks', TRUE); - // Throughout this test, some modules may be automatically enabled (due to - // dependencies). We'll keep track of them in an array, so we can handle - // them separately. - $automatically_enabled = array(); - // Go through each module in the list and try to enable it (unless it was // already enabled automatically due to a dependency). foreach ($modules as $name => $module) { @@ -443,6 +455,8 @@ class ModuleDependencyTestCase extends ModuleTestCase { * Tests enabling a module that depends on a module which fails hook_requirements(). */ function testEnableRequirementsFailureDependency() { + module_enable(array('comment')); + $this->assertModules(array('requirements1_test'), FALSE); $this->assertModules(array('requirements2_test'), FALSE); @@ -472,9 +486,12 @@ class ModuleDependencyTestCase extends ModuleTestCase { $this->resetAll(); $this->assertModules(array('module_test'), TRUE); variable_set('dependency_test', 'dependency'); - // module_test creates a dependency chain: forum depends on poll, which - // depends on php. The correct enable order is, php, poll, forum. - $expected_order = array('php', 'poll', 'forum'); + // module_test creates a dependency chain: + // - forum depends on taxonomy, comment, and poll (via module_test) + // - taxonomy depends on options + // - poll depends on php (via module_test) + // The correct enable order is: + $expected_order = array('comment', 'options', 'taxonomy', 'php', 'poll', 'forum'); // Enable the modules through the UI, verifying that the dependency chain // is correct. @@ -482,14 +499,17 @@ class ModuleDependencyTestCase extends ModuleTestCase { $edit['modules[Core][forum][enable]'] = 'forum'; $this->drupalPost('admin/modules', $edit, t('Save configuration')); $this->assertModules(array('forum'), FALSE); - $this->assertText(t('You must enable the Poll, PHP Filter modules to install Forum.'), t('Dependency chain created.')); + $this->assertText(t('You must enable the Taxonomy, Options, Comment, Poll, PHP Filter modules to install Forum.')); + $edit['modules[Core][options][enable]'] = 'options'; + $edit['modules[Core][taxonomy][enable]'] = 'taxonomy'; + $edit['modules[Core][comment][enable]'] = 'comment'; $edit['modules[Core][poll][enable]'] = 'poll'; $edit['modules[Core][php][enable]'] = 'php'; $this->drupalPost('admin/modules', $edit, t('Save configuration')); - $this->assertModules(array('forum', 'poll', 'php'), TRUE); + $this->assertModules(array('forum', 'poll', 'php', 'comment', 'taxonomy', 'options'), TRUE); // Check the actual order which is saved by module_test_modules_enabled(). - $this->assertIdentical(variable_get('test_module_enable_order', FALSE), $expected_order, t('Modules enabled in the correct order.')); + $this->assertIdentical(variable_get('test_module_enable_order', array()), $expected_order); } /** @@ -499,6 +519,7 @@ class ModuleDependencyTestCase extends ModuleTestCase { // Enable the forum module. $edit = array('modules[Core][forum][enable]' => 'forum'); $this->drupalPost('admin/modules', $edit, t('Save configuration')); + $this->drupalPost(NULL, array(), t('Continue')); $this->assertModules(array('forum'), TRUE); // Disable forum and comment. Both should now be installed but disabled. @@ -874,10 +895,13 @@ class AccessDeniedTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp(); + parent::setUp(array('block')); // Create an administrative user. $this->admin_user = $this->drupalCreateUser(array('access administration pages', 'administer site configuration', 'administer blocks')); + + user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access user profiles')); + user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access user profiles')); } function testAccessDenied() { @@ -885,34 +909,34 @@ class AccessDeniedTestCase extends DrupalWebTestCase { $this->assertText(t('Access denied'), t('Found the default 403 page')); $this->assertResponse(403); + // Use a custom 403 page. $this->drupalLogin($this->admin_user); $edit = array( - 'title' => $this->randomName(10), - 'body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => $this->randomName(100)))), + 'site_403' => 'user/' . $this->admin_user->uid, ); - $node = $this->drupalCreateNode($edit); - - // Use a custom 403 page. - $this->drupalPost('admin/config/system/site-information', array('site_403' => 'node/' . $node->nid), t('Save configuration')); + $this->drupalPost('admin/config/system/site-information', $edit, t('Save configuration')); - $this->drupalLogout(); - $this->drupalGet('admin'); - $this->assertText($node->title, t('Found the custom 403 page')); + // Enable the user login block. + $edit = array( + 'blocks[user_login][region]' => 'sidebar_first', + ); + $this->drupalPost('admin/structure/block', $edit, t('Save blocks')); // Logout and check that the user login block is shown on custom 403 pages. $this->drupalLogout(); - $this->drupalGet('admin'); - $this->assertText($node->title, t('Found the custom 403 page')); + $this->assertText($this->admin_user->name, t('Found the custom 403 page')); $this->assertText(t('User login'), t('Blocks are shown on the custom 403 page')); // Log back in and remove the custom 403 page. $this->drupalLogin($this->admin_user); - $this->drupalPost('admin/config/system/site-information', array('site_403' => ''), t('Save configuration')); + $edit = array( + 'site_403' => '', + ); + $this->drupalPost('admin/config/system/site-information', $edit, t('Save configuration')); // Logout and check that the user login block is shown on default 403 pages. $this->drupalLogout(); - $this->drupalGet('admin'); $this->assertText(t('Access denied'), t('Found the default 403 page')); $this->assertResponse(403); @@ -939,9 +963,6 @@ class AccessDeniedTestCase extends DrupalWebTestCase { class PageNotFoundTestCase extends DrupalWebTestCase { protected $admin_user; - /** - * Implement getInfo(). - */ public static function getInfo() { return array( 'name' => '404 functionality', @@ -950,32 +971,29 @@ class PageNotFoundTestCase extends DrupalWebTestCase { ); } - /** - * Implement setUp(). - */ function setUp() { parent::setUp(); // Create an administrative user. $this->admin_user = $this->drupalCreateUser(array('administer site configuration')); - $this->drupalLogin($this->admin_user); + + user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access user profiles')); + user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access user profiles')); } function testPageNotFound() { + $this->drupalLogin($this->admin_user); $this->drupalGet($this->randomName(10)); $this->assertText(t('Page not found'), t('Found the default 404 page')); + // Use a custom 404 page. $edit = array( - 'title' => $this->randomName(10), - 'body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => $this->randomName(100)))), + 'site_404' => 'user/' . $this->admin_user->uid, ); - $node = $this->drupalCreateNode($edit); - - // Use a custom 404 page. - $this->drupalPost('admin/config/system/site-information', array('site_404' => 'node/' . $node->nid), t('Save configuration')); + $this->drupalPost('admin/config/system/site-information', $edit, t('Save configuration')); $this->drupalGet($this->randomName(10)); - $this->assertText($node->title, t('Found the custom 404 page')); + $this->assertText($this->admin_user->name, t('Found the custom 404 page')); } } @@ -994,7 +1012,10 @@ class SiteMaintenanceTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp(); + parent::setUp(array('node')); + + // Configure 'node' as front page. + variable_set('site_frontpage', 'node'); // Create a user allowed to access site in maintenance mode. $this->user = $this->drupalCreateUser(array('access site in maintenance mode')); @@ -1295,7 +1316,9 @@ class PageTitleFiltering extends DrupalWebTestCase { * Implement setUp(). */ function setUp() { - parent::setUp(); + parent::setUp(array('node')); + + $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); $this->content_user = $this->drupalCreateUser(array('create page content', 'access content', 'administer themes', 'administer site configuration')); $this->drupalLogin($this->content_user); @@ -1394,13 +1417,15 @@ class FrontPageTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp('system_test'); + parent::setUp(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')); $this->drupalLogin($this->admin_user); $this->node_path = "node/" . $this->drupalCreateNode(array('promote' => 1))->nid; + // Configure 'node' as front page. + variable_set('site_frontpage', 'node'); // Enable front page logging in system_test.module. variable_set('front_page_output', 1); } @@ -1436,8 +1461,6 @@ class FrontPageTestCase extends DrupalWebTestCase { } class SystemBlockTestCase extends DrupalWebTestCase { - protected $profile = 'testing'; - public static function getInfo() { return array( 'name' => 'Block functionality', @@ -1517,20 +1540,18 @@ class SystemMainContentFallback extends DrupalWebTestCase { } function setUp() { - parent::setUp('system_test'); + parent::setUp(array('block', 'system_test')); // Create and login admin user. $this->admin_user = $this->drupalCreateUser(array( 'access administration pages', 'administer site configuration', 'administer modules', - 'administer blocks', - 'administer nodes', )); $this->drupalLogin($this->admin_user); // Create a web user. - $this->web_user = $this->drupalCreateUser(array('access user profiles', 'access content')); + $this->web_user = $this->drupalCreateUser(array('access user profiles')); } /** @@ -1538,10 +1559,6 @@ class SystemMainContentFallback extends DrupalWebTestCase { */ function testMainContentFallback() { $edit = array(); - // Disable the dashboard module, which depends on the block module. - $edit['modules[Core][dashboard][enable]'] = FALSE; - $this->drupalPost('admin/modules', $edit, t('Save configuration')); - $this->assertText(t('The configuration options have been saved.'), t('Modules status has been updated.')); // Disable the block module. $edit['modules[Core][block][enable]'] = FALSE; $this->drupalPost('admin/modules', $edit, t('Save configuration')); @@ -1589,8 +1606,6 @@ class SystemMainContentFallback extends DrupalWebTestCase { * Tests for the theme interface functionality. */ class SystemThemeFunctionalTest extends DrupalWebTestCase { - protected $profile = 'testing'; - public static function getInfo() { return array( 'name' => 'Theme interface functionality', diff --git a/core/modules/taxonomy/taxonomy.test b/core/modules/taxonomy/taxonomy.test index 00fc26941a26..f8f7ed867f13 100644 --- a/core/modules/taxonomy/taxonomy.test +++ b/core/modules/taxonomy/taxonomy.test @@ -9,6 +9,19 @@ * Class with common helper methods. */ class TaxonomyWebTestCase extends DrupalWebTestCase { + function setUp() { + $modules = func_get_args(); + if (isset($modules[0]) && is_array($modules[0])) { + $modules = $modules[0]; + } + $modules[] = 'taxonomy'; + parent::setUp($modules); + + // Create Basic page and Article node types. + if ($this->profile != 'standard') { + $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); + } + } /** * Returns a new vocabulary with random properties. @@ -193,7 +206,7 @@ class TaxonomyVocabularyUnitTest extends TaxonomyWebTestCase { } function setUp() { - parent::setUp('taxonomy', 'field_test'); + parent::setUp(array('field_test')); $admin_user = $this->drupalCreateUser(array('create article content', 'administer taxonomy')); $this->drupalLogin($admin_user); $this->vocabulary = $this->createVocabulary(); @@ -477,6 +490,7 @@ class TaxonomyTermUnitTest extends TaxonomyWebTestCase { * Test for legacy node bug. */ class TaxonomyLegacyTestCase extends TaxonomyWebTestCase { + protected $profile = 'standard'; public static function getInfo() { return array( @@ -487,7 +501,7 @@ class TaxonomyLegacyTestCase extends TaxonomyWebTestCase { } function setUp() { - parent::setUp('taxonomy'); + parent::setUp(); $this->admin_user = $this->drupalCreateUser(array('administer taxonomy', 'administer nodes', 'bypass node access')); $this->drupalLogin($this->admin_user); } @@ -524,7 +538,7 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase { } function setUp() { - parent::setUp('taxonomy'); + parent::setUp(); $this->admin_user = $this->drupalCreateUser(array('administer taxonomy', 'bypass node access')); $this->drupalLogin($this->admin_user); $this->vocabulary = $this->createVocabulary(); @@ -637,8 +651,7 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase { // Enable tags in the vocabulary. $instance = $this->instance; $instance['widget'] = array('type' => 'taxonomy_autocomplete'); - $instance['bundle'] = 'page'; - field_create_instance($instance); + field_update_instance($instance); $terms = array( 'term1' => $this->randomName(), 'term2' => $this->randomName(), @@ -655,7 +668,7 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase { $edit[$instance['field_name'] . "[$langcode]"] = drupal_implode_tags($terms); // Preview and verify the terms appear but are not created. - $this->drupalPost('node/add/page', $edit, t('Preview')); + $this->drupalPost('node/add/article', $edit, t('Preview')); foreach ($terms as $term) { $this->assertText($term, t('The term appears on the node preview')); } @@ -663,11 +676,11 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase { $this->assertTrue(empty($tree), t('The terms are not created on preview.')); // taxonomy.module does not maintain its static caches. - drupal_static_reset(); + taxonomy_terms_static_reset(); // Save, creating the terms. - $this->drupalPost('node/add/page', $edit, t('Save')); - $this->assertRaw(t('@type %title has been created.', array('@type' => t('Basic page'), '%title' => $edit["title"])), t('The node was created successfully')); + $this->drupalPost('node/add/article', $edit, t('Save')); + $this->assertRaw(t('@type %title has been created.', array('@type' => t('Article'), '%title' => $edit["title"])), t('The node was created successfully')); foreach ($terms as $term) { $this->assertText($term, t('The term was saved and appears on the node page')); } @@ -952,7 +965,7 @@ class TaxonomyRSSTestCase extends TaxonomyWebTestCase { } function setUp() { - parent::setUp('taxonomy'); + parent::setUp(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(); @@ -1045,7 +1058,7 @@ class TaxonomyTermIndexTestCase extends TaxonomyWebTestCase { } function setUp() { - parent::setUp('taxonomy'); + parent::setUp(); // Create an administrative user. $this->admin_user = $this->drupalCreateUser(array('administer taxonomy', 'bypass node access')); @@ -1328,7 +1341,7 @@ class TaxonomyHooksTestCase extends TaxonomyWebTestCase { } function setUp() { - parent::setUp('taxonomy', 'taxonomy_test'); + parent::setUp(array('taxonomy_test')); $taxonomy_admin = $this->drupalCreateUser(array('administer taxonomy')); $this->drupalLogin($taxonomy_admin); } diff --git a/core/modules/tracker/tracker.test b/core/modules/tracker/tracker.test index 7c7663fa85dc..c6d4a29c3a4b 100644 --- a/core/modules/tracker/tracker.test +++ b/core/modules/tracker/tracker.test @@ -35,6 +35,8 @@ class TrackerTest extends DrupalWebTestCase { function setUp() { parent::setUp('comment', 'tracker'); + $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); + $permissions = array('access comments', 'create page content', 'post comments', 'skip comment approval'); $this->user = $this->drupalCreateUser($permissions); $this->other_user = $this->drupalCreateUser($permissions); @@ -108,7 +110,7 @@ class TrackerTest extends DrupalWebTestCase { $this->assertText($other_published_my_comment->title, t("Nodes that the user has commented on appear in the user's tracker listing.")); // Verify that unpublished comments are removed from the tracker. - $admin_user = $this->drupalCreateUser(array('administer comments', 'access user profiles')); + $admin_user = $this->drupalCreateUser(array('post comments', 'administer comments', 'access user profiles')); $this->drupalLogin($admin_user); $this->drupalPost('comment/1/edit', array('status' => COMMENT_NOT_PUBLISHED), t('Save')); $this->drupalGet('user/' . $this->user->uid . '/track'); diff --git a/core/modules/translation/translation.test b/core/modules/translation/translation.test index 687f95236390..e2b83584f63b 100644 --- a/core/modules/translation/translation.test +++ b/core/modules/translation/translation.test @@ -9,6 +9,8 @@ * Functional tests for the Translation module. */ class TranslationTestCase extends DrupalWebTestCase { + protected $profile = 'standard'; + protected $book; public static function getInfo() { diff --git a/core/modules/user/user.test b/core/modules/user/user.test index 2d55efff4533..81d3e0712768 100644 --- a/core/modules/user/user.test +++ b/core/modules/user/user.test @@ -442,6 +442,8 @@ class UserLoginTestCase extends DrupalWebTestCase { * Test cancelling a user. */ class UserCancelTestCase extends DrupalWebTestCase { + protected $profile = 'standard'; + public static function getInfo() { return array( 'name' => 'Cancel account', @@ -849,10 +851,15 @@ class UserPictureTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp(); + parent::setUp(array('image')); // Enable user pictures. variable_set('user_pictures', 1); + // Configure default user picture settings. + variable_set('user_picture_dimensions', '1024x1024'); + variable_set('user_picture_file_size', '800'); + variable_set('user_picture_style', 'thumbnail'); + $this->user = $this->drupalCreateUser(); // Test if directories specified in settings exist in filesystem. @@ -1185,6 +1192,10 @@ class UserAdminTestCase extends DrupalWebTestCase { ); } + function setUp() { + parent::setUp(array('taxonomy')); + } + /** * Registers a user and deletes it. */ @@ -1385,14 +1396,14 @@ class UserAccountLinksUnitTests extends DrupalWebTestCase { // For a logged-in user, expect the secondary menu to have links for "My // account" and "Log out". $link = $this->xpath('//ul[@id=:menu_id]/li/a[contains(@href, :href) and text()=:text]', array( - ':menu_id' => 'secondary-menu-links', + ':menu_id' => 'secondary-menu', ':href' => 'user', ':text' => 'My account', )); $this->assertEqual(count($link), 1, 'My account link is in secondary menu.'); $link = $this->xpath('//ul[@id=:menu_id]/li/a[contains(@href, :href) and text()=:text]', array( - ':menu_id' => 'secondary-menu-links', + ':menu_id' => 'secondary-menu', ':href' => 'user/logout', ':text' => 'Log out', )); @@ -1403,7 +1414,7 @@ class UserAccountLinksUnitTests extends DrupalWebTestCase { $this->drupalGet('<front>'); // For a logged-out user, expect no secondary links. - $element = $this->xpath('//ul[@id=:menu_id]', array(':menu_id' => 'secondary-menu-links')); + $element = $this->xpath('//ul[@id=:menu_id]', array(':menu_id' => 'secondary-menu')); $this->assertEqual(count($element), 0, 'No secondary-menu for logged-out users.'); } } @@ -1420,6 +1431,26 @@ class UserBlocksUnitTests extends DrupalWebTestCase { ); } + function setUp() { + parent::setUp(array('block')); + + // Enable user login block. + db_merge('block') + ->key(array( + 'module' => 'user', + 'delta' => 'login', + 'theme' => variable_get('theme_default', 'stark'), + )) + ->fields(array( + 'status' => 1, + 'weight' => 0, + 'region' => 'sidebar_first', + 'pages' => '', + 'cache' => -1, + )) + ->execute(); + } + /** * Test the user login block. */ @@ -1679,12 +1710,32 @@ class UserSignatureTestCase extends DrupalWebTestCase { // Enable user signatures. variable_set('user_signatures', 1); - // Prefetch text formats. - $this->full_html_format = filter_format_load('full_html'); + // Create Basic page node type. + $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); + + // Prefetch and create text formats. $this->plain_text_format = filter_format_load('plain_text'); + $filtered_html_format = array( + 'format' => 'filtered_html', + 'name' => 'Filtered HTML', + ); + $this->filtered_html_format = (object) $filtered_html_format; + filter_format_save($this->filtered_html_format); + + $full_html_format = array( + 'format' => 'full_html', + 'name' => 'Full HTML', + ); + $this->full_html_format = (object) $full_html_format; + filter_format_save($this->full_html_format); + + user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array(filter_permission_name($this->filtered_html_format))); + $this->checkPermissions(array(), TRUE); + // Create regular and administrative users. - $this->web_user = $this->drupalCreateUser(array()); + $this->web_user = $this->drupalCreateUser(array('post comments')); + $admin_permissions = array('administer comments'); foreach (filter_formats() as $format) { if ($permission = filter_permission_name($format)) { @@ -1943,6 +1994,10 @@ class UserUserSearchTestCase extends DrupalWebTestCase { ); } + function setUp() { + parent::setUp(array('search')); + } + function testUserSearch() { $user1 = $this->drupalCreateUser(array('access user profiles', 'search content', 'use advanced search')); $this->drupalLogin($user1); diff --git a/profiles/testing/testing.info b/profiles/testing/testing.info index 8e353eda07cc..fff3df26f204 100644 --- a/profiles/testing/testing.info +++ b/profiles/testing/testing.info @@ -3,3 +3,5 @@ description = Minimal profile for running tests. Includes absolutely required mo version = VERSION core = 8.x hidden = TRUE +; @todo Remove dependency on Node module. +dependencies[] = node diff --git a/profiles/testing/testing.install b/profiles/testing/testing.install index afd6d1ca48d7..bdd6154d77a0 100644 --- a/profiles/testing/testing.install +++ b/profiles/testing/testing.install @@ -14,4 +14,9 @@ function testing_install() { // Allow visitor account creation, but with administrative approval. variable_set('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL); + + // Enable default permissions for system roles. + // @todo Remove dependency on Node module. + user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access content')); + user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access content')); } -- GitLab