예제 #1
0
 public function testGetModelFromJobRepository()
 {
     $job = new TestAction([], $this->jobRepository);
     $job->insert();
     $newJob = $this->jobRepository->get($job->id->getValue());
     $this->AssertEquals(get_class($job), get_class($newJob));
 }
예제 #2
0
 public function testTableCleaned()
 {
     $job = new TestAction([], $this->jobRepository);
     $job->insert();
     //
     $api = $this->getApiInstance();
     $api->exec();
     //
     $this->assertEquals(0, sizeof($this->jobRepository->getData()));
 }
 /**
  * @group debug
  */
 public function testDelete()
 {
     $job = new TestAction([], $this->jobRepository);
     $job->get(1);
     $job->delete();
     try {
         $job = new TestAction([], $this->jobRepository);
         $job->get(1);
         $this->fail('NotFoundException should be raised');
     } catch (NotFoundException $e) {
     }
 }
예제 #4
0
 public function testStatusSetToCanceled()
 {
     $fixture = 'my_uniq_fixture';
     //
     $job = new TestAction([], $this->jobRepository);
     $job->status = TestAction::NewStatus;
     $job->hash = $fixture;
     $job->insert();
     //
     $api = $this->getApiInstance(['id' => $job->id->getValue()]);
     $api->Exec();
     //
     $job = $this->jobRepository->get($job->id->getValue());
     $this->AssertEquals(TestAction::CanceledStatus, $job->status->getValue());
     $this->assertEquals($fixture, $job->hash->getValue());
 }
예제 #5
0
 public function testNewTaskCreated()
 {
     $fixture = 'some_fixture';
     //
     $job = new TestAction([], $this->jobRepository);
     $job->status = TestAction::FinishedStatus;
     $job->hash = $fixture;
     $job->insert();
     //
     $api = $this->getApiInstance(['id' => $job->id->getValue(), 'actionDate' => '']);
     $newId = $api->exec();
     //
     $newJob = $this->jobRepository->get($newId);
     $this->assertEquals($newJob->hash->getValue(), $fixture);
     $this->assertEquals($newJob->status->getValue(), TestAction::NewStatus);
 }
예제 #6
0
 public function setUp()
 {
     parent::setUp();
     $this->configurationRepository = new ConfigurationRepository(new SampleConfigurationDataSource());
     $this->jobRepository = new SampleJobRepository();
     $this->diContainer = new SampleDIAdapter();
     $this->diContainer->add(DefinitionNames::jobRepositoryService, DiDefinition::createDefinition()->setInstance($this->jobRepository));
     $this->setRunnerTimeout(0);
     TestAction::setUp();
 }
예제 #7
0
 public function testLastRecordsReturned()
 {
     $count = 2;
     $data = ['first', 'second', 'third'];
     foreach ($data as $row) {
         $job = new TestAction([], $this->jobRepository);
         $job->hash = $row;
         $job->insert();
     }
     $this->configurationRepository->get()->sampleSize = $count;
     $api = $this->getApiInstance();
     $result = $api->exec();
     //
     $this->assertTrue(is_array($result));
     $this->assertEquals($count, sizeof($result));
     // check order
     $this->assertEquals(3, $result[0]['id']);
     $this->assertEquals('third', $result[0]['hash']);
     $this->assertEquals(2, $result[1]['id']);
     $this->assertEquals('second', $result[1]['hash']);
 }
예제 #8
0
 public function testRunnerNotWorksOnSystemRegisterFlag()
 {
     $this->configurationRepository->get()->running = 0;
     //
     $job = new TestAction([], $this->jobRepository);
     $job->insert();
     //
     $runner = $this->getRunnerInstance();
     $runner->resolveJobs();
     //
     $this->assertFalse(TestAction::isCalled());
     $job = $this->jobRepository->get($job->id->getValue());
     $this->assertEquals(TestAction::NewStatus, $job->status->getValue());
 }