Index: skinr_ui.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/skinr/skinr_ui.info,v
retrieving revision 1.3
diff -u -p -r1.3 skinr_ui.info
--- skinr_ui.info	8 Dec 2010 22:06:58 -0000	1.3
+++ skinr_ui.info	16 Jan 2011 17:21:57 -0000
@@ -1,14 +1,8 @@
 ;$Id: skinr_ui.info,v 1.3 2010/12/08 22:06:58 jgirlygirl Exp $
-
 name = Skinr UI
 description = Administrative interface to skinr. Without this module, you cannot edit your skins.
 package = Skinr
 core = 7.x
-
+configure = admin/appearance/skinr
 dependencies[] = skinr
-
-files[] = skinr_ui.module
-files[] = skinr_ui.admin.inc
-files[] = skinr_ui.rules.inc
-
-configure = admin/appearance/skinr
\ No newline at end of file
+files[] = tests/skinr_ui.test
Index: tests/skinr_ui.test
===================================================================
RCS file: tests/skinr_ui.test
diff -N tests/skinr_ui.test
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/skinr_ui.test	16 Jan 2011 19:34:02 -0000
@@ -0,0 +1,123 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Tests for the Skinr UI module.
+ */
+
+/**
+ * Tests UI functionality.
+ *
+ * @todo Rename and split this test case into several ones, once we have a
+ *   certain amount of tests and an idea of how to structure them.
+ */
+class SkinrUIBasicTestCase extends DrupalWebTestCase {
+  protected $profile = 'testing';
+
+  public static function getInfo() {
+    return array(
+      'name' => 'UI',
+      'description' => 'Tests Skinr UI functionality.',
+      'group' => 'Skinr',
+    );
+  }
+
+  function setUp() {
+    parent::setUp(array('block', 'contextual', 'skinr_test', 'skinr_ui'));
+
+    $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();
+  }
+
+  /**
+   * 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/appearance/skinr/edit/nojs/block/system-user-menu/configure', array(
+      'query' => array('destination' => $front),
+    ));
+
+    // skinr_test.module got enabled in setUp(), so its skins should be
+    // available.
+    // Verify that we can apply the skinr_test_font skin to the block.
+    $edit = array(
+      'skinr_settings[block_group][bartik][widgets][skinr_test_font]' => 'font_1',
+    );
+    // 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.
+    // @todo We are going to need this kind of assertion all over again;
+    //   abstract it into a assertSkinrClass() helper method.
+    $elements = $this->xpath('//div[@id=:id]', array(':id' => 'block-system-user-menu'));
+    $class = (string) $elements[0]['class'];
+    $this->assertTrue(strpos($class, ' font-1 '), 'CSS class of configured skin option found.');
+  }
+}
