Beispiel #1
0
 public function buildReport()
 {
     $messageCollector = new MessageCollector();
     $pdo = Database::connect();
     $dao = new ReportDAO($pdo);
     $repository = new ReportRepository();
     $repository->setDAO($dao);
     $report = new Report();
     $report->setMessageCollector($messageCollector);
     $report->setRepository($repository);
     return $report;
 }
Beispiel #2
0
 public function buildTask()
 {
     $messageCollector = new MessageCollector();
     $pdo = Database::connect();
     $dao = new TaskDAO($pdo);
     $repository = new TaskRepository();
     $repository->setDAO($dao);
     $task = new Task();
     $task->setMessageCollector($messageCollector);
     $task->setRepository($repository);
     return $task;
 }
Beispiel #3
0
 public function setUp()
 {
     $messageCollector = new MessageCollector();
     $this->pdo = Database::connect();
     $this->dao = new TaskDAO($this->pdo);
     $this->repository = new TaskRepository();
     $this->repository->setDAO($this->dao);
     $this->task = new Task();
     $this->task->setMessageCollector($messageCollector);
     $this->task->setRepository($this->repository);
     parent::setUp();
 }
Beispiel #4
0
 public function testStatusChange()
 {
     $pdo = Database::connect();
     $date = new \DateTimeImmutable();
     $string = 'this is a description for status changes' . microtime(true);
     $statement = $pdo->prepare('INSERT INTO task (description, dueDate, status, deleted) values (:description, :dueDate, :status, :deleted)');
     $statement->execute(array(':description' => $string, ':dueDate' => $date->format('Y-m-d H:i:s'), ':status' => 1, ':deleted' => 0));
     $id = $pdo->lastInsertId();
     //----------------------------------------------------------------------
     $_POST['id'] = $id;
     $_POST['status'] = 0;
     $_SERVER['REQUEST_METHOD'] = 'POST';
     $newRequest = new Request();
     $factory = new EntityFactory();
     $taskAggregate = new TaskAggregate();
     $taskAggregate->setFactory($factory);
     $response = $taskAggregate->changeTaskStatus($newRequest);
     $this->assertEquals(1, $response->getData()->success);
     $statement = $pdo->prepare('SELECT * FROM task WHERE id=:id AND status=:status');
     $statement->execute(array(':id' => $id, ':status' => 0));
     $newResult = $statement->fetch();
     $this->assertNotEmpty($newResult);
     $stmt = $pdo->prepare('DELETE FROM task WHERE id = :id');
     $stmt->execute(array(':id' => $id));
 }