MediaWiki
REL1_19
|
00001 <?php 00002 00003 abstract class SeleniumTestSuite extends PHPUnit_Framework_TestSuite { 00004 private $selenium; 00005 private $isSetUp = false; 00006 private $loginBeforeTests = true; 00007 private $triggerClientTestResources = true; 00008 00009 // Do not add line break after test output 00010 const CONTINUE_LINE = 1; 00011 const RESULT_OK = 2; 00012 const RESULT_ERROR = 3; 00013 00014 public abstract function addTests(); 00015 00016 public function setUp() { 00017 // Hack because because PHPUnit version 3.0.6 which is on prototype does not 00018 // run setUp as part of TestSuite::run 00019 if ( $this->isSetUp ) { 00020 return; 00021 } 00022 $this->isSetUp = true; 00023 $this->selenium = Selenium::getInstance(); 00024 $this->selenium->start(); 00025 if ( $this->triggerClientTestResources ) { 00026 $this->selenium->open( $this->selenium->getUrl() . '/index.php?setupTestSuite=' . $this->getName() ); 00027 //wait a little longer for the db operation 00028 $this->selenium->waitForPageToLoad( 6000 ); 00029 } 00030 if ( $this->loginBeforeTests ) { 00031 $this->login(); 00032 } 00033 } 00034 00035 public function tearDown() { 00036 if ( $this->triggerClientTestResources ) { 00037 $this->selenium->open( $this->selenium->getUrl() . '/index.php?clearTestSuite=' . $this->getName() ); 00038 } 00039 $this->selenium->stop(); 00040 } 00041 00042 public function login() { 00043 $this->selenium->login(); 00044 } 00045 00046 public function loadPage( $title, $action ) { 00047 $this->selenium->loadPage( $title, $action ); 00048 } 00049 00050 protected function setLoginBeforeTests( $loginBeforeTests = true ) { 00051 $this->loginBeforeTests = $loginBeforeTests; 00052 } 00053 00054 protected function setTriggerClientTestResources( $triggerClientTestResources = true ) { 00055 $this->triggerClientTestResources = $triggerClientTestResources; 00056 } 00057 }