Exemplo n.º 1
0
 public function testFactoryByIdMethod()
 {
     $job = new TestAction();
     $job->insert();
     $newJob = Job::factoryById($job->id->getValue());
     $this->AssertEquals(get_class($job), get_class($newJob));
 }
Exemplo n.º 2
0
 public function testTableCleaned()
 {
     $job = new TestAction();
     $job->insert();
     //
     $api = new RestartServer();
     $api->exec();
     //
     $this->assertEquals(0, DBSimple::getRowsCount(TestAction::TableName));
 }
Exemplo n.º 3
0
 public function testNewTaskCreated()
 {
     $fixture = 'some_fixture';
     //
     $job = new TestAction();
     $job->status = TestAction::FinishedStatus;
     $job->hash = $fixture;
     $job->insert();
     //
     $api = new Restart(['id' => $job->id->getValue(), 'actionDate' => '']);
     $newId = $api->exec();
     //
     $newJob = TestAction::getById($newId);
     $this->assertEquals($newJob->hash->getValue(), $fixture);
     $this->assertEquals($newJob->status->getValue(), TestAction::NewStatus);
 }
Exemplo n.º 4
0
 public function testLastRecordsReturned()
 {
     $count = 2;
     $data = ['first', 'second', 'third'];
     foreach ($data as $row) {
         $job = new TestAction();
         $job->hash = $row;
         $job->insert();
     }
     Configure::write(Latests::ConfigureKey, $count);
     $api = new Latests();
     $result = $api->exec();
     //
     $this->assertTrue(is_array($result));
     $this->assertEquals(2, 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']);
 }
Exemplo n.º 5
0
 public function setUp()
 {
     parent::setUp();
     Helper::dbFixture(Job::TableName, array());
     $this->setRunnerTimeout(0);
     Restorator::restore();
     Helper::setupUsers([['login' => self::Login, 'password' => self::Password], ['login' => 'guest', 'password' => self::Password]]);
     $user = \UserAccount::getByLogin(self::Login);
     \ACL::create(\CMSAuth::SystemAdministratorRoleName);
     \ACL::grant(\CMSAuth::SystemAdministratorRoleName, $user->rights->getEntity());
     \UsersLogin::forceLogin($user);
     TestAction::setUp();
 }
Exemplo n.º 6
0
 public function testStatusSetToCanceled()
 {
     $fixture = 'my_uniq_fixture';
     //
     $job = new TestAction();
     $job->status = TestAction::NewStatus;
     $job->hash = $fixture;
     $job->insert();
     //
     $api = new Cancel(['id' => $job->id->getValue()]);
     $api->Exec();
     //
     $job = TestAction::getById($job->id->getValue());
     $this->AssertEquals(TestAction::CanceledStatus, $job->status->getValue());
     $this->assertEquals($fixture, $job->hash->getValue());
 }
Exemplo n.º 7
0
 public function testRunnerNotWorksOnSystemRegisterFlag()
 {
     $register = new \SystemRegister('System/Schedule');
     $register->runningFlag->value = 0;
     \SystemRegisterSample::createCache();
     //
     $job = new TestAction();
     $job->insert();
     //
     $runner = new Runner();
     $runner->resolveJobs();
     //
     $this->assertFalse(TestAction::isCalled());
     $job = TestAction::getById($job->id->getValue());
     $this->assertEquals(TestAction::NewStatus, $job->status->getValue());
 }