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