| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556 | 
							- <?php
 
- /**
 
-  * @file
 
-  * Tests for the Skinr UI module.
 
-  */
 
- /**
 
-  * Base class for Skinr UI tests.
 
-  */
 
- class SkinrUITestCase extends DrupalWebTestCase {
 
-   protected $profile = 'testing';
 
-   function setUp() {
 
-     $modules = func_get_args();
 
-     if (isset($modules[0]) && is_array($modules[0])) {
 
-       $modules = $modules[0];
 
-     }
 
-     parent::setUp(array_merge(array('block', 'comment', 'contextual', 'skinr_ui', 'skinr_ui_test'), $modules));
 
-     $this->admin_user = $this->drupalCreateUser(array(
 
-       'administer blocks',
 
-       'access contextual links',
 
-       'administer skinr',
 
-       'edit skin settings',
 
-       'edit advanced skin settings',
 
-     ));
 
-     $this->drupalLogin($this->admin_user);
 
-     // Enable main system block for content region and the user menu block for
 
-     // the first sidebar.
 
-     // @see http://drupal.org/node/913086
 
-     $default_theme = variable_get('theme_default', 'bartik');
 
-     db_merge('block')
 
-       ->key(array(
 
-         'theme' => $default_theme,
 
-         'module' => 'system',
 
-         'delta' => 'main',
 
-       ))
 
-       ->fields(array(
 
-         'status' => 1,
 
-         'region' => 'content',
 
-         'pages' => '',
 
-       ))
 
-       ->execute();
 
-     db_merge('block')
 
-       ->key(array(
 
-         'theme' => $default_theme,
 
-         'module' => 'system',
 
-         'delta' => 'user-menu',
 
-       ))
 
-       ->fields(array(
 
-         'status' => 1,
 
-         'region' => 'sidebar_first',
 
-         'pages' => '',
 
-       ))
 
-       ->execute();
 
-     db_merge('block')
 
-       ->key(array(
 
-         'theme' => $default_theme,
 
-         'module' => 'search',
 
-         'delta' => 'form',
 
-       ))
 
-       ->fields(array(
 
-         'status' => 1,
 
-         'region' => 'sidebar_first',
 
-         'pages' => '',
 
-       ))
 
-       ->execute();
 
-   }
 
-   /**
 
-    * Asserts that a class is set for the given element id.
 
-    *
 
-    * @param $id
 
-    *   Id of the HTML element to check.
 
-    * @param $class
 
-    *   The class name to check for.
 
-    * @param $message
 
-    *   Message to display.
 
-    * @return
 
-    *   TRUE on pass, FALSE on fail.
 
-    */
 
-   function assertSkinrClass($id, $class, $message = '') {
 
-     $elements = $this->xpath('//div[@id=:id]', array(':id' => $id));
 
-     $class_attr = (string) $elements[0]['class'];
 
-     $this->assertTrue(strpos($class_attr, ' ' . $class . ' '), $message);
 
-   }
 
-   /**
 
-    * Asserts that a class is not set for the given element id.
 
-    *
 
-    * @param $id
 
-    *   Id of the HTML element to check.
 
-    * @param $class
 
-    *   The class name to check for.
 
-    * @param $message
 
-    *   Message to display.
 
-    * @return
 
-    *   TRUE on pass, FALSE on fail.
 
-    */
 
-   function assertNoSkinrClass($id, $class, $message = '') {
 
-     $elements = $this->xpath('//div[@id=:id]', array(':id' => $id));
 
-     $class_attr = (string) $elements[0]['class'];
 
-     $this->assertFalse(strpos($class_attr, ' ' . $class . ' '), $message);
 
-   }
 
- }
 
- /**
 
-  * Tests UI functionality.
 
-  */
 
- class SkinrUIBasicTestCase extends SkinrUITestCase {
 
-   public static function getInfo() {
 
-     return array(
 
-       'name' => 'UI',
 
-       'description' => 'Tests basic Skinr UI functionality.',
 
-       'group' => 'Skinr',
 
-     );
 
-   }
 
-   /**
 
-    * Tests basic configuration and applying of a skin.
 
-    *
 
-    * @todo For some reason, contextual links are not visible in the debug output
 
-    *   when running tests; likely a core bug in contextual.js. However, the
 
-    *   links are contained in the output. Keep this in mind when manually
 
-    *   reviewing the debug output after running tests!
 
-    * @todo Remove the overly verbose inline comments after the Skinr development
 
-    *   team has figured out how to write tests.
 
-    */
 
-   function testSkinEdit() {
 
-     // Go to the front page, on which the user menu block should appear.
 
-     $this->drupalGet('');
 
-     // Click the first (index 0) 'Edit skin' link on the page, which should be
 
-     // the link in the contextual links of the user menu block, since no other
 
-     // skinnable elements are visible on the page.
 
-     // For now, this is a simple way to assert and access Skinr links. In the
 
-     // future, we want to be more explicit in testing; i.e., verify that there
 
-     // is really only this link, its 'href' is correct, that it appears in the
 
-     // right location, etc.pp; DrupalWebTestCase ($this) provides many helper
 
-     // functions to assert such things.
 
-     $this->clickLink(t('Edit skin'), 0);
 
-     // Verify that we end up on the expected URL to configure skins for the
 
-     // user menu block.
 
-     $front = variable_get('site_frontpage', 'node');
 
-     $this->assertUrl('admin/structure/skinr/edit/nojs/block/system__user-menu/configure', array(
 
-       'query' => array('destination' => $front),
 
-     ));
 
-     // skinr_ui_test.module got enabled in setUp(), so its skins should be
 
-     // available.
 
-     // Verify that we can apply the skinr_ui_test_border skin to the block.
 
-     $edit = array(
 
-       'skinr_settings[block_type][bartik][groups][general][skinr_ui_test_bgcolor]' => 'bgcolor_red',
 
-     );
 
-     // NULL means that we want to post to the page that is still contained in
 
-     // SimpleTest's internal browser; i.e., the page of the path above. Instead
 
-     // of passing NULL, you can also pass a Drupal system path and SimpleTest
 
-     // will automatically do a $this->drupalGet($path) for you before posting.
 
-     $this->drupalPost(NULL, $edit, t('Save'));
 
-     // After posting, we expect to be redirected to the originating page, due
 
-     // to the 'destination' query parameter in the 'Edit skin' link. Since we
 
-     // came from the front page, Drupal will redirect us to the actual path of
 
-     // the front page, not ''.
 
-     // Verify that we were redirected to the originating page.
 
-     $this->assertUrl($front);
 
-     // Verify that the skin has been applied.
 
-     $this->assertSkinrClass('block-system-user-menu', 'bgcolor-red', 'CSS class of configured skin option found.');
 
-   }
 
-   /**
 
-    * Tests access control for editing additional CSS classes.
 
-    */
 
-   function testSkinAdditionalEdit() {
 
-     // Verify that we can apply additional CSS classes.
 
-     $edit = array(
 
-       'skinr_settings[block_type][bartik][groups][_additional][_additional]' => 'additional',
 
-     );
 
-     $this->drupalPost('admin/structure/skinr/edit/nojs/block/system__user-menu/configure', $edit, t('Save'));
 
-     // Verify that the skin has been applied.
 
-     $this->drupalGet('');
 
-     $this->assertSkinrClass('block-system-user-menu', 'additional', 'Additional CSS class <em>additional</em> of configured skin option found.');
 
-     // Now let's check the same for a user that has no access to alter this.
 
-     $user = $this->drupalCreateUser(array('edit skin settings'));
 
-     $this->drupalLogin($user);
 
-     // Verify that the additional CSS classes field is not enabled.
 
-     $this->drupalGet('admin/structure/skinr/edit/nojs/block/system__user-menu/configure');
 
-     $this->assertNoFieldByName('skinr_settings[block_type][bartik][groups][_additional][_additional]', NULL, 'Additional CSS classes field is not enabled for this user.');
 
-     // Save form when additional CSS classes is not set.
 
-     $edit = array();
 
-     $this->drupalPost(NULL, $edit, t('Save'));
 
-     // Verify that the old class is still applied.
 
-     $this->drupalGet('');
 
-     $this->assertSkinrClass('block-system-user-menu', 'additional', 'Additional CSS class <em>additional</em> of configured skin option found.');
 
-   }
 
-   /**
 
-    * Tests output of widgets on the skin configuration form.
 
-    */
 
-   function testSkinEditWidgets() {
 
-     // Go to the edit page for system__user_menu block.
 
-     $this->drupalGet('admin/structure/skinr/library');
 
-     $this->drupalGet('admin/structure/skinr/edit/nojs/block/system__user-menu/configure');
 
-     // Check the widgets.
 
-     $this->assertFieldByName('skinr_settings[block_type][bartik][groups][general][skinr_ui_test_bgcolor]', NULL, 'Widget with valid type is displayed.');
 
-     $this->assertNoFieldByName('skinr_settings[block_type][bartik][groups][box][skinr_ui_test_border]', NULL, 'Widget with invalid type is not displayed.');
 
-     $this->assertFieldByName('skinr_settings[block_type][bartik][groups][general][skinr_ui_test_custom][custom]', NULL, 'Widget with form callback is displayed.');
 
-     // Check for output from empty groups.
 
-     $this->assertNoRaw('id="edit-skinr-settings-block-group-bartik-box"', 'Resulting empty group is not displayed.');
 
-   }
 
-   /**
 
-    * Tests access control for editing additional CSS classes.
 
-    */
 
-   function testSkinEditThemeHooks() {
 
-     // Widget should appear for system blocks.
 
-     $this->drupalGet('admin/structure/skinr/edit/nojs/block/system__user-menu/configure');
 
-     $this->assertField('edit-skinr-settings-block-type-bartik-groups-general-skinr-ui-test-color-color-white', 'The widget, which is limited to system blocks, appeared on the configuration form for system\'s user-menu block.');
 
-     // Widget should not appear search blocks.
 
-     $this->drupalGet('admin/structure/skinr/edit/nojs/block/search__form/configure');
 
-     $this->assertNoField('edit-skinr-settings-block-type-bartik-groups-general-skinr-ui-test-color-color-white', 'The widget, which is limited to system blocks, did not appear on the configuration form for search\'s form block.');
 
-     // Widget should appear for page node comments.
 
-     $this->drupalGet('admin/structure/skinr/edit/nojs/comment/page/configure');
 
-     $this->assertField('edit-skinr-settings-comment-type-bartik-groups-general-skinr-ui-test-color-color-white', 'The widget, which is limited to page node comments, appeared on the configuration form for page node comments.');
 
-     // Widget should not appear for article node comments.
 
-     $this->drupalGet('admin/structure/skinr/edit/nojs/comment/article/configure');
 
-     $this->assertNoField('edit-skinr-settings-comment-type-bartik-groups-general-skinr-ui-test-color-color-white', 'The widget, which is limited to page node comments, did not appear on the configuration form for article node comments.');
 
-     // Widget should appear for page nodes.
 
-     $this->drupalGet('admin/structure/skinr/edit/nojs/node/page/configure');
 
-     $this->assertField('edit-skinr-settings-node-type-bartik-groups-general-skinr-ui-test-color-color-white', 'The widget, which is limited to page node types, appeared on the configuration form for page node types.');
 
-     // Widget should not appear for article nodes.
 
-     $this->drupalGet('admin/structure/skinr/edit/nojs/node/article/configure');
 
-     $this->assertNoField('edit-skinr-settings-node-type-bartik-groups-general-skinr-ui-test-color-color-white', 'The widget, which is limited to page node types, did not appear on the configuration form for article node types.');
 
-   }
 
- }
 
- /**
 
-  * Tests administrative pages functionality.
 
-  */
 
- class SkinrUIAdminTestCase extends SkinrUITestCase {
 
-   public static function getInfo() {
 
-     return array(
 
-       'name' => 'Administration',
 
-       'description' => 'Tests administrative Skinr UI functionality.',
 
-       'group' => 'Skinr',
 
-     );
 
-   }
 
-   function setUp() {
 
-     parent::setUp(array('skinr_test'));
 
-     $this->admin_user = $this->drupalCreateUser(array(
 
-       'administer skinr',
 
-       'edit skin settings',
 
-       'edit advanced skin settings',
 
-     ));
 
-     $this->drupalLogin($this->admin_user);
 
-     // Enable Garland and skinr_test_subtheme without enabling its base theme in
 
-     // order to test subtheme inheritance functionality.
 
-     theme_enable(array('garland', 'skinr_test_subtheme'));
 
-   }
 
-   /**
 
-    * Tests default status of skins.
 
-    *
 
-    * The skinr_test_basetheme skin defined by the skinr_test_basetheme theme
 
-    * specifies a default status for itself. Its subtheme should inherit the
 
-    * status of the basetheme.
 
-    *
 
-    * @todo Add assertions for 'default status' itself.
 
-    */
 
-   function testSkinDefaultStatus() {
 
-     // Verify that it is enabled for the skinr_test_subtheme.
 
-     $this->drupalGet('admin/structure/skinr/library/list/skinr_test_subtheme');
 
-     $this->assertFieldChecked('edit-skins-general-skinr-test-basetheme-enable', 'skinr_test_basetheme skin is enabled for skinr_test_subtheme.');
 
-     // Verify that it is disabled for Bartik by default.
 
-     $this->drupalGet('admin/structure/skinr/library/list/bartik');
 
-     $this->assertNoFieldChecked('edit-skins-general-skinr-test-basetheme-enable', 'skinr_test_basetheme skin is disabled for Bartik.');
 
-     // Verify that it is disabled for Garland by default.
 
-     $this->drupalGet('admin/structure/skinr/library/list/garland');
 
-     $this->assertNoFieldChecked('edit-skins-general-skinr-test-basetheme-enable', 'skinr_test_basetheme skin is disabled for Garland.');
 
-     // Override the status for skinr_test_subtheme and Bartik, then verify them.
 
-     $skin = (object) array(
 
-       'theme' => 'skinr_test_subtheme',
 
-       'module' => 'block',
 
-       'element' => 'system-user-menu',
 
-       'skin' => 'skinr_test_subtheme',
 
-       'options' => array('option1', 'option2'),
 
-       'status' => 1,
 
-     );
 
-     skinr_skin_save($skin);
 
-     $skin = skinr_skin_load($skin->sid);
 
-     // Override the default skin.
 
-     $skin->element = 'system-main';
 
-     $this->drupalGet('admin/structure/skinr');
 
-     $this->clickLink(t('disable'), 0);
 
-     // Unaltered skin configuration object should have been saved with only the status updated.
 
-     // Load an uncached version of the skin configuration object.
 
-     $skin = skinr_skin_load_unchanged($skin->sid);
 
-     $this->assertFalse($skin->status, 'Status was disabled successfully.');
 
-     $this->assertEqual($skin->element, 'system-user-menu', 'Only status was updated, even though the object was modified before updating status.');
 
-     // Enable the skin configuration.
 
-     $this->drupalGet('admin/structure/skinr');
 
-     $this->clickLink(t('enable'), 0);
 
-     // Load an uncached version of the skin configuration object.
 
-     $skin = skinr_skin_load_unchanged($skin->sid);
 
-     $this->assertTrue($skin->status, 'Status was enabled successfully.');
 
-   }
 
-   /**
 
-    * Tests skin group functionality.
 
-    */
 
-   function testSkinGroups() {
 
-     $this->drupalGet('admin/structure/skinr/library');
 
-     // Verify that the 'General' (default) group appears.
 
-     $this->assertText(t('General'));
 
-     // Verify that the 'Box styles' group appears, since skinr_ui_test module
 
-     // registers a skin in that group.
 
-     $this->assertText(t('Box styles'));
 
-   }
 
-   /**
 
-    * Tests skin configuration listing functionality.
 
-    */
 
-   function testSkinListing() {
 
-     $skin = (object) array(
 
-       'theme' => 'skinr_test_subtheme',
 
-       'module' => 'block',
 
-       'element' => 'system__user-menu',
 
-       'skin' => 'skinr_test_subtheme',
 
-       'options' => array('option1', 'option2'),
 
-       'status' => 1,
 
-     );
 
-     skinr_skin_save($skin);
 
-     // Verify that the skin configuration appears on the skin configurations overview page.
 
-     $this->drupalGet('admin/structure/skinr');
 
-     $this->assertLinkByHref('admin/structure/skinr/skin/' . $skin->sid . '/delete?destination=admin/structure/skinr', 0, 'Skin configuration was found on overview page.');
 
-     // @todo Should we check the filtering and update options functionality?
 
-   }
 
- }
 
- /**
 
-  * Tests rules administrative pages functionality.
 
-  */
 
- class SkinrUIRulesTestCase extends SkinrUITestCase {
 
-   public static function getInfo() {
 
-     return array(
 
-       'name' => 'Rules UI',
 
-       'description' => 'Tests rules functionality for Skinr UI.',
 
-       'group' => 'Skinr',
 
-     );
 
-   }
 
-   /**
 
-    * Tests administrative interface for rules.
 
-    */
 
-   function testRules() {
 
-     // Test that there is a rules page.
 
-     $this->drupalGet('admin/structure/skinr');
 
-     $this->assertLinkByHref('admin/structure/skinr/rules');
 
-     // Test that there is a way to add rules.
 
-     $this->drupalGet('admin/structure/skinr/rules');
 
-     $this->clickLink(t('Create a new rule'), 0);
 
-     // Verify that we end up on the expected URL.
 
-     $this->assertUrl('admin/structure/skinr/rules/add');
 
-     // Verify that we can create the rule.
 
-     $edit = array(
 
-       'rule[title]' => 'Rule 1',
 
-       'rule[rule_type]' => 'page',
 
-     );
 
-     $this->drupalPost(NULL, $edit, t('Add'));
 
-     // After posting, we expect to be redirected to the rule edit page.
 
-     $this->assertUrl('admin/structure/skinr/rules/1/edit');
 
-     // Save rule.
 
-     // @todo Add a skin and test whether it applies properly or not.
 
-     $edit = array(
 
-     );
 
-     $this->drupalPost(NULL, $edit, t('Save rule'));
 
-     // We should be returned back to the rules page.
 
-     $this->assertUrl('admin/structure/skinr/rules');
 
-     // Make sure the new rule appears listed on this page.
 
-     $this->assertLinkByHref('admin/structure/skinr/rules/1/edit');
 
-   }
 
- }
 
- /**
 
-  * Tests UI functionality for Block plugin.
 
-  */
 
- class SkinrUIPluginTestCase extends DrupalWebTestCase {
 
-   public static function getInfo() {
 
-     return array(
 
-       'name' => 'Plugins UI - Core',
 
-       'description' => 'Tests Skinr UI functionality for functionality plugins from Drupal core.',
 
-       'group' => 'Skinr',
 
-     );
 
-   }
 
-   function setUp() {
 
-     parent::setUp(array('block', 'comment', 'node', 'skinr_ui'));
 
-     $this->admin_user = $this->drupalCreateUser(array(
 
-       'administer blocks',
 
-       'access comments',
 
-       'access content',
 
-       'post comments',
 
-       'skip comment approval',
 
-       'access contextual links',
 
-       'administer skinr',
 
-       'edit skin settings',
 
-       'edit advanced skin settings',
 
-       'bypass node access',
 
-     ));
 
-     $this->drupalLogin($this->admin_user);
 
-   }
 
-   /**
 
-    * Tests block plugin.
 
-    */
 
-   function testBlock() {
 
-     // Enable user menu block for the first sidebar.
 
-     // @see http://drupal.org/node/913086
 
-     $default_theme = variable_get('theme_default', 'bartik');
 
-     db_merge('block')
 
-       ->key(array(
 
-         'theme' => $default_theme,
 
-         'module' => 'system',
 
-         'delta' => 'user-menu',
 
-       ))
 
-       ->fields(array(
 
-         'status' => 1,
 
-         'region' => 'sidebar_first',
 
-         'pages' => '',
 
-       ))
 
-       ->execute();
 
-     // Get front page.
 
-     $this->drupalGet('');
 
-     // Make sure our contextual link appears on the page.
 
-     $this->assertLinkByHref('admin/structure/skinr/edit/nojs/block/system__user-menu/configure', 0, 'Contexual link to edit block\'s skin configuration was found.');
 
-   }
 
-   /**
 
-    * Tests comment plugin.
 
-    */
 
-   function testComment() {
 
-     // Create a node.
 
-     $node1 = $this->drupalCreateNode(array('type' => 'article'));
 
-     // Go to node.
 
-     $uri = entity_uri('node', $node1);
 
-     $this->drupalGet($uri['path']);
 
-     // Add a comment to the node. With bartik the contextual links won't
 
-     // display until there is at least one comment.
 
-     $edit = array(
 
-       'comment_body[und][0][value]' => $this->randomString(128),
 
-     );
 
-     $this->drupalPost(NULL, $edit, t('Save'));
 
-     // Make sure our contextual link appears on the page.
 
-     $this->assertLinkByHref('admin/structure/skinr/edit/nojs/comment/article/configure', 0, 'Contexual link to edit comment\'s skin configuration was found.');
 
-   }
 
-   /**
 
-    * Tests node plugin.
 
-    */
 
-   function testNode() {
 
-     // Create a node.
 
-     $node = $this->drupalCreateNode(array('type' => 'article'));
 
-     // Go to node.
 
-     $uri = entity_uri('node', $node);
 
-     $this->drupalGet($uri['path']);
 
-     // Make sure our contextual link appears on the page.
 
-     $this->assertLinkByHref('admin/structure/skinr/edit/nojs/node/article/configure', 0, 'Contexual link to edit node\'s skin configuration was found.');
 
-   }
 
- }
 
- /**
 
-  * Tests UI functionality for Block plugin.
 
-  */
 
- /**
 
-  * Tests UI functionality for Block plugin.
 
-  */
 
- class SkinrUIPluginViewsTestCase extends DrupalWebTestCase {
 
-   public static function getInfo() {
 
-     return array(
 
-       'name' => 'Plugins UI - Views',
 
-       'description' => 'Tests Skinr UI functionality for functionality plugin from Views.',
 
-       'dependencies' => array('views', 'views_ui'),
 
-       'group' => 'Skinr',
 
-     );
 
-   }
 
-   function setUp() {
 
-     parent::setUp(array('views_ui', 'skinr_ui_test'));
 
-     $this->admin_user = $this->drupalCreateUser(array(
 
-       'administer views',
 
-       'access all views',
 
-       'access contextual links',
 
-       'administer skinr',
 
-       'edit skin settings',
 
-       'edit advanced skin settings',
 
-     ));
 
-     $this->drupalLogin($this->admin_user);
 
-   }
 
-   /**
 
-    * Tests views plugin.
 
-    */
 
-   function testViews() {
 
-     // Go to the view's page.
 
-     $this->drupalGet('skinr-ui-test-view');
 
-     // Make sure our contextual link appears on the page.
 
-     $this->assertLinkByHref('admin/structure/skinr/edit/nojs/views/skinr_ui_test__page/configure', 0, "Contexual link to edit view's skin configuration was found.");
 
-   }
 
- }
 
 
  |