--- modules/simpletest/tests/theme.original.test	2010-08-29 21:09:49.629733973 +0200
+++ modules/simpletest/tests/theme.test	2010-08-29 22:14:50.159733875 +0200
@@ -216,3 +216,132 @@ class ThemeFastTestCase extends DrupalWe
     $this->assertText('registry not initialized', t('The registry was not initialized'));
   }
 }
+
+/**
+ * Functional test for input button output.
+ */
+class ThemeImageButtonOutputTest extends DrupalWebTestCase {
+  function setUp() {
+    parent::setUp();
+  }
+
+  function getInfo() {
+    return array(
+      'name' => 'Theme image button output',
+      'description' => 'Make sure that the output of the theme_image_button() is right.',
+      'group' => 'Theme',
+    );
+  }
+
+  /**
+   * Test that the theme system is properly outputing an image button.
+   */
+  function testImageButtonOutput() {
+    global $base_url;
+    $this->button = array(
+      'element' => array(
+        '#name' => $this->randomName(),
+        '#title' => $this->randomName(),
+        '#src' => 'misc/arrow-asc.png',
+        '#id' => $this->randomName(),
+        '#button_type' => 'image',
+      ),
+    );
+    // Generate the output.
+    $this->content = theme_image_button($this->button);
+
+    // Short name helpers.
+    $name = $this->button['element']['#name'];
+    $title = $this->button['element']['#title'];
+    $misc = $base_url . '/' . $this->button['element']['#src'];
+    $id = $this->button['element']['#id'];
+    $type = $this->button['element']['#button_type'];
+    // Class attribute automaticly added by the theme_image_button generation.
+    $class = 'class="form-' . $type . '"';
+    $output = '<input type="image" name="' . $name . '" id="' . $id . '" src="' . $misc . '" alt="' . $title . '" title="' . $title . '" '. $class . ' />';
+    $this->assertRaw($output, 'Display an image button');
+    $this->verbose($this->content);
+  }
+  
+  /**
+   * Test that the theme system is properly outputing
+   * an image button with attributes.
+   */
+  function testImageButtonMulticlassOutput() {
+    global $base_url;
+    $this->button = array(
+      'element' => array(
+        '#name' => $this->randomName(),
+        '#title' => $this->randomName(),
+        '#src' => 'misc/arrow-asc.png',
+        '#id' => $this->randomName(),
+        '#button_type' => 'image',
+        '#attributes' => array(
+          'rel' => $this->randomName(),
+          'class' => array(
+            $this->randomName(),
+            $this->randomName(),
+          ),
+        ),
+      ),
+    );
+    // Generate the output.
+    $this->content = theme_image_button($this->button);
+
+    // Short name helpers.
+    $name = $this->button['element']['#name'];
+    $title = $this->button['element']['#title'];
+    $misc = $base_url . '/' . $this->button['element']['#src'];
+    $id = $this->button['element']['#id'];
+    $type = $this->button['element']['#button_type'];
+    // Class attribute automaticly added by the theme_image_button generation.
+    $this->button['element']['#attributes']['class'][] = 'form-' . $type;
+    $attributes = drupal_attributes($this->button['element']['#attributes']);
+    $output = '<input ' . $attributes . ' type="image" name="' . $name . '" id="' . $id . '" src="' . $misc . '" alt="' . $title . '" title="' . $title . '" />';
+    debug(check_plain($output));
+    $this->assertRaw($output, 'Display an image button having attributes');
+    $this->verbose($this->content);
+  }
+  
+  /**
+   * Test that the theme system is properly outputing a disabled image button.
+   */
+  function testImageButtonDisabledOutput() {
+    global $base_url;
+    $this->button = array(
+      'element' => array(
+        '#name' => $this->randomName(),
+        '#title' => $this->randomName(),
+        '#src' => 'misc/arrow-asc.png',
+        '#id' => $this->randomName(),
+        '#button_type' => 'image',
+        '#attributes' => array(
+          'rel' => $this->randomName(),
+          'disabled' => 'disabled',
+          'class' => array(
+            $this->randomName(),
+            $this->randomName(),
+          ),
+        ),
+      ),
+    );
+    // Generate the output.
+    $this->content = theme_image_button($this->button);
+
+    // Short name helpers.
+    $name = $this->button['element']['#name'];
+    $title = $this->button['element']['#title'];
+    $misc = $base_url . '/' . $this->button['element']['#src'];
+    $id = $this->button['element']['#id'];
+    $type = $this->button['element']['#button_type'];
+    // Class attribute automaticly added by the theme_image_button generation
+    // and the disabled attribute.
+    $this->button['element']['#attributes']['class'][] = 'form-' . $type;
+    $this->button['element']['#attributes']['class'][] = 'form-button-disabled';
+    $attributes = drupal_attributes($this->button['element']['#attributes']);
+    $output = '<input ' . $attributes . ' type="image" name="' . $name . '" id="' . $id . '" src="' . $misc . '" alt="' . $title . '" title="' . $title . '" />';
+    debug(check_plain($output));
+    $this->assertRaw($output, 'Display a disabled image button');
+    $this->verbose($this->content);
+  }
+}
\ Pas de fin de ligne à la fin du fichier.
