Ejemplo n.º 1
0
 public function testCreateANewLockWithId1234AndUpdateItPassingThenDeleteIt()
 {
     $this->cleanAndPopulateDatabase();
     $request = new Request(['id' => '1234']);
     /** @var \Tasker\UseCase\Lock\Create $useCase */
     $useCase = UseCaseFactory::make('lock|create');
     $useCase->setRequest($request);
     $useCase->execute();
     $request = new Request([['id' => '1234'], ['id' => '6789']]);
     /** @var \Tasker\UseCase\Lock\Update $useCase */
     $useCase = UseCaseFactory::make('lock|update');
     $useCase->setRequest($request);
     $useCase->execute();
     /** @var \Tasker\Boundary\Response $response */
     $response = $useCase->getResponse();
     /** @var array $result */
     $result = $response->getResult();
     $this->assertInstanceOf('MultiTierArchitecture\\Entity\\Definition\\EntityInterface', $result[0]);
     $this->assertEquals('6789', $result[0]->getId());
     /** @var \Tasker\UseCase\Lock\Delete $useCase */
     $useCase = UseCaseFactory::make('lock|delete');
     $useCase->setRequest(new Request(['id' => '6789']));
     $useCase->execute();
     /** @var \Tasker\Boundary\Response $response */
     $response = $useCase->getResponse();
     /** @var array $result */
     $result = $response->getResult();
     $this->assertTrue(empty($result[0]));
 }
Ejemplo n.º 2
0
 public function executeUseCase($useCaseString, RequestAbstract $request)
 {
     /** @var \MultiTierArchitecture\UseCase\Definition\BaseAbstract $useCase */
     $useCase = Factory::make($useCaseString);
     $useCase->setRequest($request);
     $useCase->execute();
     $this->useCase = $useCase;
     $this->useCaseResponse = $useCase->getResponse();
     $this->useCaseTotalResultCount = $this->useCaseResponse->getTotalResultCount();
     $this->useCaseResponseStatus = $this->useCaseResponse->getStatus();
 }
Ejemplo n.º 3
0
 public function testRetrieve2()
 {
     //$this->cleanAndPopulateDatabase();
     $request = new Request(['sql' => ['statement' => 'SELECT * FROM :table1: WHERE ((startingDateTime + repeatingInterval) ' . '< now()) AND ((statusId != ' . 2 . ') AND ' . '(statusId != ' . 3 . ')) AND ' . '(server IS NOT NULL) ORDER BY priority DESC LIMIT ' . 0 . ',1;', 'statementForCount' => 'SELECT * FROM :table1: WHERE ((startingDateTime + repeatingInterval) ' . '< now()) AND ((statusId != 1) AND (statusId != 2)) AND ' . '(server IS NOT NULL);']]);
     $useCase = UseCaseFactory::make('task|retrieve');
     $useCase->setRequest($request);
     $useCase->execute();
     /** @var \Tasker\Boundary\Response $response */
     $response = $useCase->getResponse();
     /** @var array $result */
     $resultCount = $response->getTotalResultCount();
     $this->assertGreaterThan(0, $resultCount);
 }
Ejemplo n.º 4
0
 public function testCreateANewTaskWithId12345()
 {
     $this->cleanAndPopulateDatabase();
     $request = new Request(['server' => 'server1234|5678', 'creatingDateTime' => '2014-04-08 10:10:10']);
     /** @var \Tasker\UseCase\Task\Create $useCase */
     $useCase = UseCaseFactory::make('task|create');
     $useCase->setRequest($request);
     $useCase->execute();
     $request = new Request(['server' => 'server1234|5678']);
     $useCase = UseCaseFactory::make('task|retrieve');
     $useCase->setRequest($request);
     $useCase->execute();
     /** @var \Tasker\Boundary\Response $response */
     $response = $useCase->getResponse();
     /** @var array $result */
     $result = $response->getResult();
     $this->assertInstanceOf('MultiTierArchitecture\\Entity\\Definition\\EntityInterface', $result[0]);
     $this->assertEquals('server1234|5678', $result[0]->getServer());
 }
Ejemplo n.º 5
0
 public function testCreate()
 {
     $this->cleanAndPopulateDatabase();
     $request = new Request(['id' => '12345', 'creatingDateTime' => '2014-04-08 10:10:10']);
     /** @var \Tasker\UseCase\Lock\Create $useCase */
     $useCase = UseCaseFactory::make('lock|create');
     $useCase->setRequest($request);
     $useCase->execute();
     $useCase->execute();
     //
     //        $request = new Request(['id' => '12345']);
     //        $useCase = UseCaseFactory::make('lock|retrieve');
     //        $useCase->setRequest($request);
     //        $useCase->execute();
     //
     //        /** @var \Tasker\Boundary\Response $response */
     //        $response = $useCase->getResponse();
     //        /** @var array $result */
     //        $result = $response->getResult();
     //
     //        $this->assertInstanceOf('MultiTierArchitecture\Entity\Definition\EntityInterface', $result[0]);
     //        $this->assertEquals('12345', $result[0]->getId());
 }