theming_example.test 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * @file
  4. * Simpletest case for theming_example module.
  5. */
  6. /**
  7. * Functional tests for the theming example module.
  8. *
  9. * @ingroup theming_example
  10. */
  11. class ThemingExampleTestCase extends DrupalWebTestCase {
  12. /**
  13. * {@inheritdoc}
  14. */
  15. public static function getInfo() {
  16. return array(
  17. 'name' => 'Theming Example',
  18. 'description' => 'Verify theming example functionality',
  19. 'group' => 'Examples',
  20. );
  21. }
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public function setUp() {
  26. // Enable the module.
  27. parent::setUp('theming_example');
  28. }
  29. /**
  30. * Verify the functionality of the example module.
  31. */
  32. public function testThemingPage() {
  33. // No need to login for this test.
  34. // Check that the main page has been themed (first line with <b>) and has
  35. // content.
  36. $this->drupalGet('examples/theming_example');
  37. $this->assertRaw('<strong>Some examples of pages');
  38. $this->assertRaw('examples/theming_example/theming_example_select_form">Simple form 1</a>');
  39. // Visit the list demonstration page and check that css gets loaded
  40. // and do some spot checks on how the two lists were themed.
  41. $this->drupalGet('examples/theming_example/theming_example_list_page');
  42. $this->assertPattern('/@import.*theming_example.css/');
  43. $first_ul = $this->xpath('//ul[contains(@class,"render-version-list")]');
  44. $this->assertTrue($first_ul[0]->li[0] == 'First item');
  45. $second_ul = $this->xpath('//ol[contains(@class,"theming-example-list")]');
  46. $this->assertTrue($second_ul[0]->li[1] == 'Second item');
  47. // Visit the select form page to do spot checks.
  48. $this->drupalGet('examples/theming_example/theming_example_select_form');
  49. // We did explicit theming to accomplish the below...
  50. $this->assertRaw('<strong>Choose which ordering you want</strong>');
  51. $this->assertRaw('<div class="container-inline"><div class="form-item form-type-select form-item-choice">');
  52. $this->assertNoPattern('/@import.*theming_example.css/');
  53. // Visit the text form page and do spot checks.
  54. $this->drupalGet('examples/theming_example/theming_example_text_form');
  55. $this->assertText('Please input something!');
  56. // If it were themed normally there would be a div wrapper in our pattern.
  57. $this->assertPattern('%</div>\s*<input +type="submit"%');
  58. }
  59. }