public function testPersistAfterExecution() { $runId = __CLASS__ . '::' . __METHOD__; $request = $this->mockRequest($runId); $runRepository = new RunRepository(); $pipeline = new Pipeline(); $response = $pipeline->execute($request); $run = $runRepository->retrieve($response->getRunId()); $this->assertNotEquals($runId, $run->getRunId()); $this->assertEquals($run->getTsAccessed(), $run->getTsCreated()); }
public function testPersistUpdatedRun() { $repository = new RunRepository(); $run = $repository->retrieve(self::$testRunIdUpdate); $run->setTsCreated($run->getTsCreated() - 3600); $run->setTsAccessed($run->getTsAccessed() - 3600); $repository->persist($run); $dbRun = $repository->retrieve($run->getRunId()); $this->assertEquals($run->getRunId(), $dbRun->getRunId()); $this->assertEquals($run->getTsCreated(), $dbRun->getTsCreated()); $this->assertGreaterThan($run->getTsAccessed(), $dbRun->getTsAccessed()); }
/** * Executes the pipeline. * * @param Request $request * @return Response */ public function execute(Request $request) { $response = new Response(); $runId = $request->getRunId(); $run = $this->runRepository->retrieve($runId); if (null === $run) { $run = $this->runRepository->create(); $runId = $run->getRunId(); } $this->runRepository->persist($run); $response->setRunId($runId); return $response; }