blob: 81a630f8ae416ba72621ffb5c7a9818707874988 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
<?php
abstract class SeleniumTestSuite extends PHPUnit_Framework_TestSuite {
private $selenium;
private $isSetUp = false;
private $loginBeforeTests = true;
private $triggerClientTestResources = true;
// Do not add line break after test output
const CONTINUE_LINE = 1;
const RESULT_OK = 2;
const RESULT_ERROR = 3;
public abstract function addTests();
public function setUp() {
// Hack because because PHPUnit version 3.0.6 which is on prototype does not
// run setUp as part of TestSuite::run
if ( $this->isSetUp ) {
return;
}
$this->isSetUp = true;
$this->selenium = Selenium::getInstance();
$this->selenium->start();
if ( $this->triggerClientTestResources ) {
$this->selenium->open( $this->selenium->getUrl() . '/index.php?setupTestSuite=' . $this->getName() );
//wait a little longer for the db operation
$this->selenium->waitForPageToLoad( 6000 );
}
if ( $this->loginBeforeTests ) {
$this->login();
}
}
public function tearDown() {
if ( $this->triggerClientTestResources ) {
$this->selenium->open( $this->selenium->getUrl() . '/index.php?clearTestSuite=' . $this->getName() );
}
$this->selenium->stop();
}
public function login() {
$this->selenium->login();
}
public function loadPage( $title, $action ) {
$this->selenium->loadPage( $title, $action );
}
protected function setLoginBeforeTests( $loginBeforeTests = true ) {
$this->loginBeforeTests = $loginBeforeTests;
}
protected function setTriggerClientTestResources( $triggerClientTestResources = true ) {
$this->triggerClientTestResources = $triggerClientTestResources;
}
}
|