27namespace Dolibarr\test\functional;
29use PHPUnit_Extensions_Selenium2TestCase_WebDriverException;
49 protected static $base_url =
'http://dev.zenfusion.fr';
54 protected static $dol_admin_user =
'admin';
59 protected static $dol_admin_pass =
'admin';
61 private static $module_id = 500000;
64 public static $browsers = array(
66 'browser' =>
'Google Chrome on Linux',
67 'browserName' =>
'chrome',
68 'sessionStrategy' =>
'shared',
69 'desiredCapabilities' => array()
92 $anchors = $this->elements($this->
using(
'tag name')->value(
'a'));
94 foreach ($anchors as $test_anchor) {
95 if (\strstr($test_anchor->attribute(
'href'), $value)) {
96 $anchor = $test_anchor;
117 $this->setSeleniumServerRequestsTimeout(3600);
118 $this->setBrowserUrl(self::$base_url);
137 if ($this->byId(
'login')) {
138 $login = $this->byId(
'username');
140 $login->value(
'admin');
141 $password = $this->byId(
'password');
143 $password->value(
'admin');
144 $this->byId(
'login')->submit();
146 }
catch (PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) {
157 $this->url(
'/admin/const.php');
159 $main_features_level_path =
'//input[@value="MAIN_FEATURES_LEVEL"]/following::input[@type="text"]';
160 $main_features_level = $this->byXPath($main_features_level_path);
161 $main_features_level->clear();
162 $main_features_level->value(
'2');
163 $this->byName(
'update')->click();
165 $main_features_level = $this->byXPath($main_features_level_path);
166 return $this->assertEquals(
'2', $main_features_level->value(),
"MAIN_FEATURES_LEVEL value is 2");
177 $this->url(
'/admin/modules.php');
179 $module_status_image_path =
'//a[contains(@href, "'.self::$module_id.
'")]/img';
180 $module_status_image = $this->byXPath($module_status_image_path);
181 if (\strstr($module_status_image->attribute(
'src'),
'switch_off.png')) {
183 $this->
byHref(
'modMyModule')->click();
186 $this->
byHref(
'modMyModule')->click();
188 $this->
byHref(
'modMyModule')->click();
191 $module_status_image = $this->byXPath($module_status_image_path);
192 return $this->assertContains(
'switch_on.png', $module_status_image->attribute(
'src'),
"Module enabled");
203 $this->url(
'/custom/mymodule/admin/setup.php');
205 return $this->assertContains(
'mymodule/admin/setup.php', $this->url(),
'Configuration page');
216 $this->url(
'/custom/mymodule/admin/about.php');
218 return $this->assertContains(
'mymodule/admin/about.php', $this->url(),
'About page');
229 $this->url(
'/custom/mymodule/admin/about.php');
231 return $this->assertEquals(
232 'Dolibarr Module Template (aka My Module)',
233 $this->byTag(
'h1')->text(),
246 $this->url(
'/admin/boxes.php');
248 return $this->assertContains(
'mymodulewidget1', $this->source(),
"Box enabled");
259 $this->url(
'/admin/triggers.php');
261 return $this->assertContains(
262 'interface_99_modMyModule_MyModuleTriggers.class.php',
263 $this->byTag(
'body')->text(),
276 $this->url(
'/admin/triggers.php');
278 return $this->assertContains(
280 $this->byXPath(
'//td[text()="interface_99_modMyModule_MyTrigger.class.php"]/following::img')->attribute(
'src'),
testBoxDeclared()
Test box is properly declared.
testModuleEnabled()
Test enabling the module.
testAboutPage()
Test access to the about page.
static tearDownAfterClass()
Global test teardown.
testConfigurationPage()
Test access to the configuration page.
assertPreConditions()
Verify pre conditions.
byHref($value)
Helper function to select links by href.
testTriggerDeclared()
Test trigger is properly enabled.
authenticate()
Handle Dolibarr authentication.
assertPostConditions()
Verify post conditions.
tearDown()
Unit test teardown.
testAboutPageRendersMarkdownReadme()
Test about page is rendering Markdown.
testEnableDeveloperMode()
Test enabling developer mode.
static setUpBeforeClass()
Global test setup.
testTriggerEnabled()
Test trigger is properly declared.