diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php index e979a5c2b6b..35a935e4bca 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php @@ -25,13 +25,6 @@ class CommentLanguageTest extends WebTestBase { */ public static $modules = array('language', 'language_test', 'comment_test'); - /** - * Use the standard profile. - * - * @todo Remove this dependency if possible. - */ - protected $profile = 'standard'; - public static function getInfo() { return array( 'name' => 'Comment language', @@ -43,8 +36,10 @@ class CommentLanguageTest extends WebTestBase { function setUp() { parent::setUp(); + $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); + // Create and login user. - $admin_user = $this->drupalCreateUser(array('administer site configuration', 'administer languages', 'access administration pages', 'administer content types', 'administer comments', 'create article content')); + $admin_user = $this->drupalCreateUser(array('administer site configuration', 'administer languages', 'access administration pages', 'administer content types', 'administer comments', 'create article content', 'access comments', 'post comments', 'skip comment approval')); $this->drupalLogin($admin_user); // Add language. diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldDisplayTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldDisplayTest.php index 9d30a2f8103..7e9094f81f6 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldDisplayTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldDisplayTest.php @@ -11,6 +11,7 @@ namespace Drupal\file\Tests; * Tests that formatters are working properly. */ class FileFieldDisplayTest extends FileFieldTestBase { + public static function getInfo() { return array( 'name' => 'File field display tests', diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldRSSContentTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldRSSContentTest.php index f69d9f7f943..12f4f08c647 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldRSSContentTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldRSSContentTest.php @@ -11,6 +11,7 @@ namespace Drupal\file\Tests; * Tests that formatters are working properly. */ class FileFieldRSSContentTest extends FileFieldTestBase { + public static function getInfo() { return array( 'name' => 'File field RSS content', diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php index 60b5f52aea8..52df6f2e882 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php @@ -21,14 +21,13 @@ abstract class FileFieldTestBase extends WebTestBase { */ public static $modules = array('file', 'file_module_test', 'field_ui'); - protected $profile = 'standard'; - protected $admin_user; function setUp() { parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array('access content', 'access administration pages', 'administer site configuration', 'administer users', 'administer permissions', 'administer content types', 'administer node fields', 'administer node display', 'administer comment fields', 'administer nodes', 'bypass node access')); + $this->admin_user = $this->drupalCreateUser(array('access content', 'access administration pages', 'administer site configuration', 'administer users', 'administer permissions', 'administer content types', 'administer node fields', 'administer node display', 'administer nodes', 'bypass node access')); $this->drupalLogin($this->admin_user); + $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); } /** diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php index 3d5f782f6fd..28a5d5d268c 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php @@ -11,6 +11,14 @@ namespace Drupal\file\Tests; * Tests file field widget. */ class FileFieldWidgetTest extends FileFieldTestBase { + + /** + * Modules to enable. + * + * @var array + */ + public static $modules = array('comment'); + public static function getInfo() { return array( 'name' => 'File field widget test', @@ -23,11 +31,7 @@ class FileFieldWidgetTest extends FileFieldTestBase { * Tests upload and remove buttons for a single-valued File field. */ function testSingleValuedWidget() { - // Use 'page' instead of 'article', so that the 'article' image field does - // not conflict with this test. If in the future the 'page' type gets its - // own default file or image field, this test can be made more robust by - // using a custom node type. - $type_name = 'page'; + $type_name = 'article'; $field_name = strtolower($this->randomName()); $this->createFileField($field_name, $type_name); $field = field_info_field($field_name); @@ -83,11 +87,7 @@ class FileFieldWidgetTest extends FileFieldTestBase { * Tests upload and remove buttons for multiple multi-valued File fields. */ function testMultiValuedWidget() { - // Use 'page' instead of 'article', so that the 'article' image field does - // not conflict with this test. If in the future the 'page' type gets its - // own default file or image field, this test can be made more robust by - // using a custom node type. - $type_name = 'page'; + $type_name = 'article'; $field_name = strtolower($this->randomName()); $field_name2 = strtolower($this->randomName()); $this->createFileField($field_name, $type_name, array('cardinality' => 3)); @@ -204,11 +204,7 @@ class FileFieldWidgetTest extends FileFieldTestBase { * Tests a file field with a "Private files" upload destination setting. */ function testPrivateFileSetting() { - // Use 'page' instead of 'article', so that the 'article' image field does - // not conflict with this test. If in the future the 'page' type gets its - // own default file or image field, this test can be made more robust by - // using a custom node type. - $type_name = 'page'; + $type_name = 'article'; $field_name = strtolower($this->randomName()); $this->createFileField($field_name, $type_name); $field = field_info_field($field_name); @@ -245,11 +241,13 @@ class FileFieldWidgetTest extends FileFieldTestBase { function testPrivateFileComment() { $user = $this->drupalCreateUser(array('access comments')); - // Remove access comments permission from anon user. - $edit = array( - DRUPAL_ANONYMOUS_RID . '[access comments]' => FALSE, - ); - $this->drupalPost('admin/people/permissions', $edit, t('Save permissions')); + // Grant the admin user required comment permissions. + user_role_grant_permissions(key($this->admin_user->roles), array('administer comment fields')); + + // Revoke access comments permission from anon user, grant post to + // authenticated. + user_role_revoke_permissions(DRUPAL_ANONYMOUS_RID, array('access comments')); + user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('post comments', 'skip comment approval')); // Create a new field. $edit = array( diff --git a/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php b/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php index 357d8bf0cc9..42c0b098b84 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php @@ -37,11 +37,7 @@ class FilePrivateTest extends FileFieldTestBase { * Tests file access for file uploaded to a private node. */ function testPrivateFile() { - // Use 'page' instead of 'article', so that the 'article' image field does - // not conflict with this test. If in the future the 'page' type gets its - // own default file or image field, this test can be made more robust by - // using a custom node type. - $type_name = 'page'; + $type_name = 'article'; $field_name = strtolower($this->randomName()); $this->createFileField($field_name, $type_name, array('uri_scheme' => 'private')); diff --git a/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php b/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php index a0d8d2893db..93ceaaf1246 100644 --- a/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php +++ b/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php @@ -18,8 +18,6 @@ class MenuTest extends WebTestBase { */ public static $modules = array('menu', 'block'); - protected $profile = 'standard'; - protected $big_user; protected $std_user; protected $menu; @@ -36,6 +34,8 @@ class MenuTest extends WebTestBase { function setUp() { parent::setUp(); + $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); + // Create users. $this->big_user = $this->drupalCreateUser(array('access administration pages', 'administer blocks', 'administer menu', 'create article content')); $this->std_user = $this->drupalCreateUser(array()); @@ -49,16 +49,15 @@ class MenuTest extends WebTestBase { $this->drupalLogin($this->big_user); $this->items = array(); - // Do standard menu tests. - $this->doStandardMenuTests(); - - // Do custom menu tests. - $this->doCustomMenuTests(); + $this->menu = $this->addCustomMenu(); + $this->doMenuTests($this->menu->id()); + $this->addInvalidMenuLink($this->menu->id()); + $this->addCustomMenuCRUD(); // Do standard user tests. // Login the user. $this->drupalLogin($this->std_user); - $this->verifyAccess(403); + $this->verifyAccess(403, $this->menu->id()); foreach ($this->items as $item) { $node = node_load(substr($item['link_path'], 5)); // Paths were set as 'node/$nid'. $this->verifyMenuLink($item, $node); @@ -89,24 +88,6 @@ class MenuTest extends WebTestBase { $this->resetMenuLink($item, $old_title); } - /** - * Tests standard menu functionality using the Tools menu. - */ - function doStandardMenuTests() { - $this->doMenuTests(); - $this->addInvalidMenuLink(); - } - - /** - * Tests custom menu functionality using the Tools menu. - */ - function doCustomMenuTests() { - $this->menu = $this->addCustomMenu(); - $this->doMenuTests($this->menu->id()); - $this->addInvalidMenuLink($this->menu->id()); - $this->addCustomMenuCRUD(); - } - /** * Add custom menu using CRUD functions. */ @@ -204,9 +185,9 @@ class MenuTest extends WebTestBase { } /** - * Tests menu functionality using the Tools menu. + * Tests menu functionality. */ - function doMenuTests($menu_name = 'tools') { + function doMenuTests($menu_name) { // Add nodes to use as links for menu links. $node1 = $this->drupalCreateNode(array('type' => 'article')); $node2 = $this->drupalCreateNode(array('type' => 'article')); @@ -552,7 +533,7 @@ class MenuTest extends WebTestBase { * * @param integer $response HTTP response code. */ - private function verifyAccess($response = 200) { + private function verifyAccess($response = 200, $menu_name = 'tools') { // View menu help node. $this->drupalGet('admin/help/menu'); $this->assertResponse($response); @@ -568,7 +549,7 @@ class MenuTest extends WebTestBase { } // View tools menu customization node. - $this->drupalGet('admin/structure/menu/manage/tools'); + $this->drupalGet('admin/structure/menu/manage/' . $menu_name); $this->assertResponse($response); if ($response == 200) { $this->assertText(t('Tools'), 'Tools menu node was displayed'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Ajax/MultiFormTest.php b/core/modules/system/lib/Drupal/system/Tests/Ajax/MultiFormTest.php index aab0858acb2..c9e7b6dd962 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Ajax/MultiFormTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Ajax/MultiFormTest.php @@ -19,8 +19,6 @@ class MultiFormTest extends AjaxTestBase { */ public static $modules = array('form_test'); - protected $profile = 'standard'; - public static function getInfo() { return array( 'name' => 'AJAX multi form', @@ -32,6 +30,8 @@ class MultiFormTest extends AjaxTestBase { function setUp() { parent::setUp(); + $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Page')); + // Create a multi-valued field for 'page' nodes to use for Ajax testing. $field_name = 'field_ajax_test'; $field = array( diff --git a/core/modules/system/lib/Drupal/system/Tests/Image/FileMoveTest.php b/core/modules/system/lib/Drupal/system/Tests/Image/FileMoveTest.php index e74b553a796..336888e6c10 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Image/FileMoveTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Image/FileMoveTest.php @@ -13,7 +13,13 @@ namespace Drupal\system\Tests\Image; * @todo This test belongs to File module. */ class FileMoveTest extends ToolkitTestBase { - protected $profile = 'standard'; + + /** + * Modules to enable. + * + * @var array + */ + public static $modules = array('image'); public static function getInfo() { return array( diff --git a/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php b/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php index 5dfd181530d..6e3dccfbc3b 100644 --- a/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php +++ b/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php @@ -20,9 +20,7 @@ class TranslationTest extends WebTestBase { * * @var array */ - public static $modules = array('translation', 'translation_test'); - - protected $profile = 'standard'; + public static $modules = array('translation', 'translation_test', 'block'); protected $book; @@ -37,6 +35,8 @@ class TranslationTest extends WebTestBase { function setUp() { parent::setUp(); + $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); + // Setup users. $this->admin_user = $this->drupalCreateUser(array('bypass node access', 'administer nodes', 'administer languages', 'administer content types', 'administer blocks', 'access administration pages', 'translate all content')); $this->translator = $this->drupalCreateUser(array('create page content', 'edit own page content', 'translate all content')); @@ -460,11 +460,14 @@ class TranslationTest extends WebTestBase { $message = format_string('[%page_language] Language switch item not found for %translation_language language in the %type page area.', $args); } + // node uses the article tag. + $tag = $type == 'node' ? 'article' : 'div'; + if (!empty($translation->nid)) { - $xpath = '//div[contains(@class, :type)]//a[@href=:url]'; + $xpath = '//' . $tag . '[contains(@class, :type)]//a[@href=:url]'; } else { - $xpath = '//div[contains(@class, :type)]//span[contains(@class, "locale-untranslated")]'; + $xpath = '//' . $tag . '[contains(@class, :type)]//span[contains(@class, "locale-untranslated")]'; } $found = $this->findContentByXPath($xpath, array(':type' => $type, ':url' => $url), $translation_language->name);