コード例 #1
0
 public function testSave()
 {
     $before = $this->object->listJobs();
     $job = $this->object->newJob('1 2 3 4 5 w');
     $this->object->add($job);
     $job2 = $this->object->newJob('2 3 4 5 6 w');
     $this->object->add($job2, '/tmp/a1');
     $this->object->save();
     $saved = $this->object->listJobs();
     $this->assertNotEquals($before, $saved);
     $this->assertNotEmpty($before);
     $this->assertNotEmpty($saved);
     $job3 = $this->object->newJob('3 4 5 6 7 w');
     $this->object->add($job3);
     $this->object->save();
     $savedSecond = $this->object->listJobs();
     $this->assertNotEmpty($savedSecond);
     $this->assertNotEquals($savedSecond, $saved);
     $this->assertNotEquals($savedSecond, $before);
     $this->assertContains($job3->render(true), $savedSecond);
     $this->assertNotContains($job3->render(true), $saved);
     $this->assertNotContains($job3->render(true), $before);
     $this->assertContains($job2->render(true), $savedSecond);
     $this->assertContains($job2->render(true), $saved);
     $this->assertNotContains($job2->render(true), $before);
     $job4 = $this->object->newJob('4 5 6 7 8 w');
     $this->object->cleanManager();
     $this->object->add($job4);
     $this->object->save(false);
     $savedThird = $this->object->listJobs();
     $this->assertContains($job4->render(true), $savedThird);
     $this->assertNotContains($job3->render(true), $savedThird);
     $this->assertNotContains($job2->render(true), $savedThird);
     $this->assertNotContains($job->render(true), $savedThird);
 }