2727 * Test WebDriver\WebDriver class
2828 *
2929 * @package WebDriver
30+ *
31+ * @group Functional
3032 */
3133class WebDriverTest extends \PHPUnit_Framework_TestCase
3234{
@@ -43,9 +45,11 @@ protected function setUp()
4345 if ($ url = getenv ('ROOT_URL ' )) {
4446 $ this ->testDocumentRootUrl = $ url ;
4547 }
48+
4649 if ($ url = getenv ('SELENIUM_URL ' )) {
4750 $ this ->testSeleniumRootUrl = $ url ;
4851 }
52+
4953 $ this ->driver = new WebDriver ($ this ->getTestSeleniumRootUrl ());
5054 $ this ->session = null ;
5155 }
@@ -63,6 +67,7 @@ protected function tearDown()
6367 /**
6468 * Returns the full url to the test site (corresponding to the root dir of the library).
6569 * You can set this via env var ROOT_URL
70+ *
6671 * @return string
6772 */
6873 protected function getTestDocumentRootUrl ()
@@ -72,6 +77,7 @@ protected function getTestDocumentRootUrl()
7277
7378 /**
7479 * Returns the full url to the Selenium server used for functional tests
80+ *
7581 * @return string
7682 *
7783 * @todo make this configurable via env var
@@ -81,19 +87,27 @@ protected function getTestSeleniumRootUrl()
8187 return $ this ->testSeleniumRootUrl ;
8288 }
8389
90+ /**
91+ * Is Selenium down?
92+ *
93+ * @param \Exception $exception
94+ *
95+ * @return boolean
96+ */
8497 protected function isSeleniumDown ($ exception )
8598 {
8699 return preg_match ('/Failed to connect to .* Connection refused/ ' , $ exception ->getMessage ()) != false
87- || strpos ($ exception ->getMessage (), 'couldn \'t connect to host ' ) !== false ;
100+ || strpos ($ exception ->getMessage (), 'couldn \'t connect to host ' ) !== false
101+ || strpos ($ exception ->getMessage (), 'Unable to connect to host ' ) !== false ;
88102 }
89103
90104 /**
91- * @group Functional
105+ * Test driver sessions
92106 */
93107 public function testSessions ()
94108 {
95109 try {
96- $ this ->assertCount (0 , $ this ->driver ->sessions ());
110+ $ this ->assertCount (0 , $ this ->driver ->sessions ());
97111
98112 $ this ->session = $ this ->driver ->session ();
99113 } catch (\Exception $ e ) {
@@ -109,7 +123,7 @@ public function testSessions()
109123 }
110124
111125 /**
112- * @group Functional
126+ * Test driver status
113127 */
114128 public function testStatus ()
115129 {
@@ -131,7 +145,6 @@ public function testStatus()
131145
132146 /**
133147 * Checks that an error connecting to Selenium gives back the expected exception
134- * @group Functional
135148 */
136149 public function testSeleniumError ()
137150 {
@@ -151,13 +164,9 @@ public function testSeleniumError()
151164
152165 /**
153166 * Checks that a successful command to Selenium which returns an http error response gives back the expected exception
154- * @group Functional
155167 */
156168 public function testSeleniumErrorResponse ()
157169 {
158- $ this ->markTestSkipped ('this test is currently broken ' ); // see https://github.com/instaclick/php-webdriver/issues/77
159- return ;
160-
161170 try {
162171 $ status = $ this ->driver ->status ();
163172 } catch (\Exception $ e ) {
@@ -171,6 +180,7 @@ public function testSeleniumErrorResponse()
171180 try {
172181 $ this ->session = $ this ->driver ->session ();
173182 $ this ->session ->open ($ this ->getTestDocumentRootUrl ().'/test/Assets/index.html ' );
183+
174184 $ element = $ this ->session ->element ('id ' , 'a-quite-unlikely-html-element-id ' );
175185
176186 $ this ->fail ('Exception not thrown while looking for missing element in page ' );
@@ -181,7 +191,6 @@ public function testSeleniumErrorResponse()
181191
182192 /**
183193 * Checks that a successful command to Selenium which returns 'nothing' according to spec does not raise an error
184- * @group Functional
185194 */
186195 public function testSeleniumNoResponse ()
187196 {
@@ -198,6 +207,7 @@ public function testSeleniumNoResponse()
198207 $ this ->session = $ this ->driver ->session ();
199208 $ timeouts = $ this ->session ->timeouts ();
200209 $ out = $ timeouts ->async_script (array ('type ' => 'implicit ' , 'ms ' => 1000 ));
210+
201211 $ this ->assertEquals (null , $ out );
202212 }
203213}
0 commit comments