From 6e95e657a7a92fffdf119572cd8cf0a6047ad059 Mon Sep 17 00:00:00 2001 From: catch Date: Mon, 28 May 2012 20:13:51 +0900 Subject: [PATCH] Issue #1591334 by aspilicious: Convert dashboard tests to PSR-0. --- core/modules/dashboard/dashboard.info | 1 - .../Tests/DashboardBlockAvailabilityTest.php | 65 +++++++++++++++++++ .../dashboard/Tests/DashboardBlocksTest.php} | 60 +---------------- 3 files changed, 68 insertions(+), 58 deletions(-) create mode 100644 core/modules/dashboard/lib/Drupal/dashboard/Tests/DashboardBlockAvailabilityTest.php rename core/modules/dashboard/{dashboard.test => lib/Drupal/dashboard/Tests/DashboardBlocksTest.php} (62%) diff --git a/core/modules/dashboard/dashboard.info b/core/modules/dashboard/dashboard.info index f98b235b930..17c0b1df0ff 100644 --- a/core/modules/dashboard/dashboard.info +++ b/core/modules/dashboard/dashboard.info @@ -3,6 +3,5 @@ description = Provides a dashboard page in the administrative interface for orga core = 8.x package = Core version = VERSION -files[] = dashboard.test dependencies[] = block configure = admin/dashboard/customize diff --git a/core/modules/dashboard/lib/Drupal/dashboard/Tests/DashboardBlockAvailabilityTest.php b/core/modules/dashboard/lib/Drupal/dashboard/Tests/DashboardBlockAvailabilityTest.php new file mode 100644 index 00000000000..41aed6f9e89 --- /dev/null +++ b/core/modules/dashboard/lib/Drupal/dashboard/Tests/DashboardBlockAvailabilityTest.php @@ -0,0 +1,65 @@ + '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. + */ + function testBlockAvailability() { + // Test "Recent comments", which should be available (defined as + // "administrative") but not enabled. + $this->drupalGet('admin/dashboard'); + $this->assertNoText(t('Recent comments'), t('"Recent comments" not on dashboard.')); + $this->drupalGet('admin/dashboard/drawer'); + $this->assertText(t('Recent comments'), t('Drawer of disabled blocks includes a block defined as "administrative".')); + $this->assertNoText(t('Syndicate'), t('Drawer of disabled blocks excludes a block not defined as "administrative".')); + $this->drupalGet('admin/dashboard/configure'); + $elements = $this->xpath('//select[@id=:id]//option[@selected="selected"]', array(':id' => 'edit-blocks-comment-recent-region')); + $this->assertTrue($elements[0]['value'] == 'dashboard_inactive', t('A block defined as "administrative" defaults to dashboard_inactive.')); + + // Now enable the block on the dashboard. + $values = array(); + $values['blocks[comment_recent][region]'] = 'dashboard_main'; + $this->drupalPost('admin/dashboard/configure', $values, t('Save blocks')); + $this->drupalGet('admin/dashboard'); + $this->assertText(t('Recent comments'), t('"Recent comments" was placed on dashboard.')); + $this->drupalGet('admin/dashboard/drawer'); + $this->assertNoText(t('Recent comments'), t('Drawer of disabled blocks excludes enabled blocks.')); + } +} diff --git a/core/modules/dashboard/dashboard.test b/core/modules/dashboard/lib/Drupal/dashboard/Tests/DashboardBlocksTest.php similarity index 62% rename from core/modules/dashboard/dashboard.test rename to core/modules/dashboard/lib/Drupal/dashboard/Tests/DashboardBlocksTest.php index 2808dc489f8..a7723886b6b 100644 --- a/core/modules/dashboard/dashboard.test +++ b/core/modules/dashboard/lib/Drupal/dashboard/Tests/DashboardBlocksTest.php @@ -2,16 +2,17 @@ /** * @file - * Tests for dashboard.module. + * Definition of Drupal\dashboard\Tests\DashboardBlocksTest. */ +namespace Drupal\dashboard\Tests; use Drupal\simpletest\WebTestBase; /** * Tests the Dashboard module blocks. */ -class DashboardBlocksTestCase extends WebTestBase { +class DashboardBlocksTest extends WebTestBase { public static function getInfo() { return array( 'name' => 'Dashboard blocks', @@ -108,58 +109,3 @@ class DashboardBlocksTestCase extends WebTestBase { $this->assertRaw($custom_block['title'], t('Block still appears on the dashboard.')); } } - -class DashboardBlockAvailabilityTestCase extends WebTestBase { - 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. - */ - function testBlockAvailability() { - // Test "Recent comments", which should be available (defined as - // "administrative") but not enabled. - $this->drupalGet('admin/dashboard'); - $this->assertNoText(t('Recent comments'), t('"Recent comments" not on dashboard.')); - $this->drupalGet('admin/dashboard/drawer'); - $this->assertText(t('Recent comments'), t('Drawer of disabled blocks includes a block defined as "administrative".')); - $this->assertNoText(t('Syndicate'), t('Drawer of disabled blocks excludes a block not defined as "administrative".')); - $this->drupalGet('admin/dashboard/configure'); - $elements = $this->xpath('//select[@id=:id]//option[@selected="selected"]', array(':id' => 'edit-blocks-comment-recent-region')); - $this->assertTrue($elements[0]['value'] == 'dashboard_inactive', t('A block defined as "administrative" defaults to dashboard_inactive.')); - - // Now enable the block on the dashboard. - $values = array(); - $values['blocks[comment_recent][region]'] = 'dashboard_main'; - $this->drupalPost('admin/dashboard/configure', $values, t('Save blocks')); - $this->drupalGet('admin/dashboard'); - $this->assertText(t('Recent comments'), t('"Recent comments" was placed on dashboard.')); - $this->drupalGet('admin/dashboard/drawer'); - $this->assertNoText(t('Recent comments'), t('Drawer of disabled blocks excludes enabled blocks.')); - } -}