Browse files

Task scheduler test

  • Loading branch information...
1 parent b2e14bf commit 7e640bec2f6cc190a87906316095c59e14970773 zoe slattery committed Oct 13, 2012
Showing with 32 additions and 7 deletions.
  1. +32 −7 tests/rtTaskSchedulerTest.php
View
39 tests/rtTaskSchedulerTest.php
@@ -6,15 +6,14 @@ class rtTaskSchedulerTest extends PHPUnit_Framework_TestCase
{
public function testResult()
{
- /* Need to rewrite this to test the PHP group runner
+ // Need to rewrite this to test the PHP group runner
$taskList = array();
$expected = array();
$results = array();
// create 10 tasks with random numbers
for ($i=0; $i<10; $i++) {
- $n = rand(0,9);
- $n = $i;
+ $n = rand(0,9);
$expected[$i] = $n+1;
$taskList[$i] = new rtTaskIncTest($n);
}
@@ -26,9 +25,20 @@ public function testResult()
$scheduler->setReportStatus(-1);
$scheduler->run();
- var_dump($scheduler->getResultList());
+
+ $actual=array();
+
+ foreach($scheduler->getResultList() as $result) {
+ $array = $result->getTestStatusList();
+ $actual[] = $array[0];
+ }
+
+ sort($actual);
+ sort($expected);
+
- $this->assertEquals($expected, $scheduler->getResultList());*/
+ $this->assertEquals($expected, $actual);
+
}
}
@@ -40,7 +50,8 @@ public function testResult()
*/
class rtTaskIncTest extends rtTask implements rtTaskInterface
{
- private $num = null;
+ protected $num = null;
+
public function __construct($num)
{
@@ -49,9 +60,23 @@ public function __construct($num)
public function run()
{
- $this->result = array($this->num+1);
+ $this->result = new rtTaskResult($this->num + 1);
+
return true;
}
+
+}
+class rtTaskResult
+{
+ private $status = array();
+
+ public function __construct($num) {
+ $this->status[] = $num;
+ }
+
+ public function getTestStatusList() {
+ return $this->status;
+ }
}
?>

0 comments on commit 7e640be

Please sign in to comment.