tablesort_example.test 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * @file
  4. * Simpletest case for tablesort_example module.
  5. */
  6. /**
  7. * Functionality tests for the tablesort example module.
  8. *
  9. * @ingroup tablesort_example
  10. */
  11. class TableSortExampleTestCase extends DrupalWebTestCase {
  12. /**
  13. * {@inheritdoc}
  14. */
  15. public static function getInfo() {
  16. return array(
  17. 'name' => 'TableSort Example',
  18. 'description' => 'Verify the tablesort functionality',
  19. 'group' => 'Examples',
  20. );
  21. }
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public function setUp() {
  26. // Enable the module.
  27. parent::setUp('tablesort_example');
  28. }
  29. /**
  30. * Verify the functionality of the example module.
  31. */
  32. public function testTableSortPage() {
  33. // No need to login for this test.
  34. $this->drupalGet('examples/tablesort_example', array('query' => array('sort' => 'desc', 'order' => 'Numbers')));
  35. $this->assertRaw('<tbody>
  36. <tr class="odd"><td class="active">7</td><td>e</td><td>t982hkv</td> </tr>', 'Ordered by Number descending');
  37. $this->drupalGet('examples/tablesort_example', array('query' => array('sort' => 'asc', 'order' => 'Numbers')));
  38. $this->assertRaw('<tbody>
  39. <tr class="odd"><td class="active">1</td><td>e</td><td>912cv21</td> </tr>', 'Ordered by Number ascending');
  40. // Sort by Letters.
  41. $this->drupalGet('examples/tablesort_example', array('query' => array('sort' => 'desc', 'order' => 'Letters')));
  42. $this->assertRaw('<tbody>
  43. <tr class="odd"><td>4</td><td class="active">w</td><td>80jsv772</td> </tr>', 'Ordered by Letters descending');
  44. $this->drupalGet('examples/tablesort_example', array('query' => array('sort' => 'asc', 'order' => 'Letters')));
  45. $this->assertRaw('<tbody>
  46. <tr class="odd"><td>2</td><td class="active">a</td><td>0kuykuh</td> </tr>', 'Ordered by Letters ascending');
  47. // Sort by Mixture.
  48. $this->drupalGet('examples/tablesort_example', array('query' => array('sort' => 'desc', 'order' => 'Mixture')));
  49. $this->assertRaw('<tbody>
  50. <tr class="odd"><td>7</td><td>e</td><td class="active">t982hkv</td> </tr>', 'Ordered by Mixture descending');
  51. $this->drupalGet('examples/tablesort_example', array('query' => array('sort' => 'asc', 'order' => 'Mixture')));
  52. $this->assertRaw('<tbody>
  53. <tr class="odd"><td>2</td><td>a</td><td class="active">0kuykuh</td> </tr>', 'Ordered by Mixture ascending');
  54. }
  55. }