27 namespace test\functional;
29 use PHPUnit_Extensions_Selenium2TestCase_WebDriverException;
48 protected static $base_url =
'http://dev.zenfusion.fr';
53 protected static $dol_admin_user =
'admin';
58 protected static $dol_admin_pass =
'admin';
60 private static $module_id = 500000;
63 public static $browsers = array(
65 'browser' =>
'Google Chrome on Linux',
66 'browserName' =>
'chrome',
67 'sessionStrategy' =>
'shared',
68 'desiredCapabilities' => array()
91 $anchors = $this->elements($this->
using(
'tag name')->value(
'a'));
92 foreach ($anchors as $anchor) {
93 if (strstr($anchor->attribute(
'href'), $value)) {
114 $this->setSeleniumServerRequestsTimeout(3600);
115 $this->setBrowserUrl(self::$base_url);
133 if ($this->byId(
'login')) {
134 $login = $this->byId(
'username');
136 $login->value(
'admin');
137 $password = $this->byId(
'password');
139 $password->value(
'admin');
140 $this->byId(
'login')->submit();
142 }
catch (PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) {
153 $this->url(
'/admin/const.php');
155 $main_features_level_path =
'//input[@value="MAIN_FEATURES_LEVEL"]/following::input[@type="text"]';
156 $main_features_level = $this->byXPath($main_features_level_path);
157 $main_features_level->clear();
158 $main_features_level->value(
'2');
159 $this->byName(
'update')->click();
161 $main_features_level = $this->byXPath($main_features_level_path);
162 return $this->assertEquals(
'2', $main_features_level->value(),
"MAIN_FEATURES_LEVEL value is 2");
173 $this->url(
'/admin/modules.php');
175 $module_status_image_path =
'//a[contains(@href, "'.self::$module_id.
'")]/img';
176 $module_status_image = $this->byXPath($module_status_image_path);
177 if (strstr($module_status_image->attribute(
'src'),
'switch_off.png')) {
179 $this->
byHref(
'modMyModule')->click();
182 $this->
byHref(
'modMyModule')->click();
184 $this->
byHref(
'modMyModule')->click();
187 $module_status_image = $this->byXPath($module_status_image_path);
188 return $this->assertContains(
'switch_on.png', $module_status_image->attribute(
'src'),
"Module enabled");
199 $this->url(
'/custom/mymodule/admin/setup.php');
201 return $this->assertContains(
'mymodule/admin/setup.php', $this->url(),
'Configuration page');
212 $this->url(
'/custom/mymodule/admin/about.php');
214 return $this->assertContains(
'mymodule/admin/about.php', $this->url(),
'About page');
225 $this->url(
'/custom/mymodule/admin/about.php');
227 return $this->assertEquals(
228 'Dolibarr Module Template (aka My Module)',
229 $this->byTag(
'h1')->text(),
242 $this->url(
'/admin/boxes.php');
244 return $this->assertContains(
'mymodulewidget1', $this->source(),
"Box enabled");
255 $this->url(
'/admin/triggers.php');
257 return $this->assertContains(
258 'interface_99_modMyModule_MyModuleTriggers.class.php',
259 $this->byTag(
'body')->text(),
272 $this->url(
'/admin/triggers.php');
274 return $this->assertContains(
276 $this->byXPath(
'//td[text()="interface_99_modMyModule_MyTrigger.class.php"]/following::img')->attribute(
'src'),
assertPostConditions()
Verify post conditions.
static tearDownAfterClass()
Global test teardown.
testEnableDeveloperMode()
Test enabling developer mode.
authenticate()
Handle Dolibarr authentication.
static setUpBeforeClass()
Global test setup.
byHref($value)
Helper function to select links by href.
testTriggerEnabled()
Test trigger is properly declared.
testAboutPageRendersMarkdownReadme()
Test about page is rendering Markdown.
testConfigurationPage()
Test access to the configuration page.
assertPreConditions()
Verify pre conditions.
testBoxDeclared()
Test box is properly declared.
testAboutPage()
Test access to the about page.
testModuleEnabled()
Test enabling the module.
testTriggerDeclared()
Test trigger is properly enabled.
tearDown()
Unit test teardown.