コード例 #1
0
ファイル: JobTest.php プロジェクト: gudwin/extasy-schedule
 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()));
 }
コード例 #3
0
 /**
  * @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
ファイル: CancelTest.php プロジェクト: gudwin/extasy-schedule
 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
ファイル: BaseTest.php プロジェクト: gudwin/extasy-schedule
 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
ファイル: RunnerTest.php プロジェクト: gudwin/extasy-schedule
 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());
 }