Skip to content

Instantly share code, notes, and snippets.

@heddn
Created October 9, 2012 20:57
Show Gist options
  • Save heddn/3861376 to your computer and use it in GitHub Desktop.
Save heddn/3861376 to your computer and use it in GitHub Desktop.
<?php
abstract class BaseTest extends PHPUnit_Extensions_SeleniumTestCase {
protected $autoStop = FALSE;
protected function setUp() {
$this->setBrowserUrl('http://www.example.com');
}
/**
* common commands required at the start of each test. These cannot be run in the setup
* as they require the browser to be opened
*/
protected function init() {
$this->clearAllCookies();
$this->openHomePage();
}
/**
* Clears all cookies
*/
private function clearAllCookies() {
$cookies = explode(';', $this->getCookie());
foreach ($cookies as $cookie) {
$cookie_parts = explode('=', $cookie);
$this->deleteCookie($cookie_parts[0], '/');
}
}
/**
* Open the homepage and verifies we are in fact on the home page
*/
private function openHomePage() {
$this->open("/");
$this->waitForPageToLoad("30000");
$this->assertEquals("Home", $this->getText("xpath=//h1[@id='page-title']"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment