Beispiel #1
0
 public function testInit()
 {
     $task = new Base($this->entityManager->recordManager);
     $this->assertTrue($task instanceof Base);
     $this->assertTrue($task instanceof Task);
     $this->assertTrue($task->execute($this->entityManager->db));
 }
Beispiel #2
0
 public function testBase1()
 {
     $base = new Base($this->entityManager->recordManager);
     $obj = new stdClass();
     $this->assertTrue($base->setObject($obj, false));
     $this->assertSame($base->getObject(), $obj);
 }
Beispiel #3
0
 public function testFilterByObject()
 {
     $response = new Response();
     $obj = new \stdClass();
     $exception = new \Exception("some exception here");
     $task1 = new Base($this->entityManager->recordManager);
     $task1->setObject($obj);
     $task2 = new Base($this->entityManager->recordManager);
     // build two task response
     $response->add('success', $task1, Response::SUCCESS);
     $response->add('failed', $task2, $exception);
     $this->assertSame(count($response), 2);
     $this->assertFalse($response->isSuccess());
     // lookup by $obj
     $responseSuccess = $response->filterByObject($obj);
     $this->assertTrue($responseSuccess->isSuccess());
     $this->assertSame(count($responseSuccess), 1);
     // lookup by task1
     $responseSuccess = $response->filterByObject($task1);
     $this->assertTrue($responseSuccess->isSuccess());
     $this->assertSame(count($responseSuccess), 1);
     // lookup by task2
     $responseFailed = $response->filterByObject($task2);
     $this->assertFalse($responseFailed->isSuccess());
     $this->assertSame(count($responseFailed), 1);
     // lookup by task1,2
     $responseAll = $response->filterByObject(array($task1, $task2));
     $this->assertFalse($responseAll->isSuccess());
     $this->assertSame(count($responseAll), 2);
 }