Commit 00722024 authored by webchick's avatar webchick
Browse files

Issue #1595028 by Berdir, sun: Convert remaining tests using Standard profile...

Issue #1595028 by Berdir, sun: Convert remaining tests using Standard profile to use Testing profile instead.
parent ef0abf20
......@@ -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 @@ public static function getInfo() {
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.
......
......@@ -11,6 +11,7 @@
* Tests that formatters are working properly.
*/
class FileFieldDisplayTest extends FileFieldTestBase {
public static function getInfo() {
return array(
'name' => 'File field display tests',
......
......@@ -11,6 +11,7 @@
* Tests that formatters are working properly.
*/
class FileFieldRSSContentTest extends FileFieldTestBase {
public static function getInfo() {
return array(
'name' => 'File field RSS content',
......
......@@ -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'));
}
/**
......
......@@ -11,6 +11,14 @@
* 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 @@ public static function getInfo() {
* 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 @@ function testSingleValuedWidget() {
* 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 @@ function testMultiValuedWidget() {
* 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 @@ function testPrivateFileSetting() {
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(
......
......@@ -37,11 +37,7 @@ public function setUp() {
* 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'));
......
......@@ -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 @@ public static function getInfo() {
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 @@ function testMenu() {
$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 @@ function testMenu() {
$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 @@ function deleteCustomMenu($menu) {
}
/**
* 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 @@ private function getStandardMenuLink() {
*
* @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 @@ private function verifyAccess($response = 200) {
}
// 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');
......
......@@ -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 @@ public static function getInfo() {
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(
......
......@@ -13,7 +13,13 @@
* @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(
......
......@@ -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 @@ public static function getInfo() {
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 @@ function assertLanguageSwitchLinks($node, $translation, $find = TRUE, $types = N
$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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment