diff --git a/tests/gmap.test b/tests/gmap.test index 3247ac0b7d7e140427777e8dc0cf68c445f70be5..07f73a39b9adca4d193e4b6d55773752278e5555 100644 --- a/tests/gmap.test +++ b/tests/gmap.test @@ -15,10 +15,10 @@ class GMapSimpleAPITest extends DrupalUnitTestCase { ); } -public function setUp(){ - drupal_load('module', 'gmap'); - parent::setUp(); -} + public function setUp() { + drupal_load('module', 'gmap'); + parent::setUp(); + } /** * Verify gmap_todim(). @@ -98,3 +98,164 @@ class GMapMacroTest extends DrupalUnitTestCase { $this->assertEqual($map['mtc'], 'standard', t('Testing tcontrol -> mtc=standard')); } } + +// wrapper for gmap.module web testing +class testGmapFormsTestCase extends DrupalWebTestCase { + protected $privileged_user; + + public static function getInfo() { + return array( + 'name' => 'GMAP Forms', + 'description' => 'GMAP Forms WebTesting.', + 'group' => 'GMap', + ); + } + + public function setUp() { + parent::setUp('gmap'); // Enable any modules required for the test + // Create and log in our user. The user has the arbitrary privilege + // 'extra special edit any simpletest_example' which the code uses + // to grant access. + $this->privileged_user = $this->drupalCreateUser(array('administer site configuration')); + $this->drupalLogin($this->privileged_user); + } + + // gmap_menu() test initial wrapper + public function testGmapSaveConfig() { + + $edit = array(); + + $this->drupalPost('admin/config/services/gmap', $edit, t('Save configuration')); + $this->assertText(t('The configuration options have been saved.')); + } + + + /** + * Detect if we're running on PIFR testbot; skip intentional failure in that + * case. It happens that on the testbot the site under test is in a directory + * named 'checkout' or 'site_under_test'. + * + * @return boolean + * TRUE if running on testbot. + */ + public function runningOnTestbot() { + return (file_exists("../checkout") || file_exists("../site_under_test")); + } +} + +// wrapper test for gmap_macro_builder module +class testGmapMacroFormsTestCase extends DrupalWebTestCase { + protected $privileged_user; + + public static function getInfo() { + return array( + 'name' => 'GMAP Macro Forms', + 'description' => 'GMAP Macro Forms WebTesting.', + 'group' => 'GMap', + ); + } + + public function setUp() { + parent::setUp('gmap_macro_builder'); // Enable any modules required for the test + drupal_load('module', 'gmap'); + drupal_load('module', 'gmap_macro_builder'); + + // Create and log in our user. The user has the arbitrary privilege + // 'extra special edit any simpletest_example' which the code uses + // to grant access. + $this->privileged_user = $this->drupalCreateUser(array('create gmap macro')); + $this->drupalLogin($this->privileged_user); + } + + // gmap_macro_builder_menu() test initial wrapper + public function testMacroMenuExampleCreate() { + $this->privileged_user = $this->drupalCreateUser(array('create gmap macro')); + $this->drupalLogin($this->privileged_user); + + $edit = array(); + + $this->drupalGet('map/macro', $edit); + $this->assertText(t('You can use this interface to create a map macro suitable for pasting into a node or any other place that accepts a GMap macro.')); + } + + + /** + * Detect if we're running on PIFR testbot; skip intentional failure in that + * case. It happens that on the testbot the site under test is in a directory + * named 'checkout' or 'site_under_test'. + * + * @return boolean + * TRUE if running on testbot. + */ + public function runningOnTestbot() { + return (file_exists("../checkout") || file_exists("../site_under_test")); + } +} + +// wrapper test for gmap_taxonomy module +class testGmapTaxonomyFormsTestCase extends DrupalWebTestCase { + protected $privileged_user; + + public static function getInfo() { + return array( + 'name' => 'GMAP Taxonomy', + 'description' => 'GMAP Taxonomy WebTesting.', + 'group' => 'GMap', + ); + } + + public function setUp() { + parent::setUp('gmap_taxonomy'); // Enable any modules required for the test + drupal_load('module', 'gmap'); + drupal_load('module', 'gmap_taxonomy'); + + // Create and log in our user. The user has the arbitrary privilege + // 'extra special edit any simpletest_example' which the code uses + // to grant access. + $this->privileged_user = $this->drupalCreateUser(array('administer taxonomy')); + $this->drupalLogin($this->privileged_user); + } + + // gmap_macro_builder_menu() test initial wrapper + public function testMacroMenuExampleCreate() { + // Create node to edit. + $rname = $this->randomName(); + $edit = array( + 'name' => $rname, + 'machine_name' => 'gmap_taxonomy_test_voc', + 'gmap_taxonomy_enable' => 1, + ); + + // create taxonomy vocabulary with gmap markers + $this->drupalPost('admin/structure/taxonomy/add', $edit, t('Save')); + $this->assertText(t('Created new vocabulary')); + + // add taxonomy term with "small red" marker + + $edit2 = array( + 'name' => $this->randomName(), + 'gmap_taxonomy_marker' => 'small red', + + ); + + $this->drupalGet('admin/structure/taxonomy/gmap_taxonomy_test_voc/add', $edit); + $this->assertText(t('GMap Marker')); + + $this->drupalPost('admin/structure/taxonomy/gmap_taxonomy_test_voc/add', $edit2, t('Save')); + $this->assertText(t('Created new term')); + + } + + + /** + * Detect if we're running on PIFR testbot; skip intentional failure in that + * case. It happens that on the testbot the site under test is in a directory + * named 'checkout' or 'site_under_test'. + * + * @return boolean + * TRUE if running on testbot. + */ + public function runningOnTestbot() { + return (file_exists("../checkout") || file_exists("../site_under_test")); + } +}