Пример #1
0
 /**
  * @testdox Each JobType has a workflow of Questions that is initially empty.
  * @test
  */
 public function workflow()
 {
     $jobType = new \App\Model\JobType();
     $jobType->name = 'test';
     $jobType->save();
     //$this->assertEquals(0, $jobType->questions->count());
 }
Пример #2
0
 public function testMerge()
 {
     // Basic merge.
     $tag1 = Tag::firstOrCreate(['name' => 'Tag 1']);
     $tag2 = Tag::firstOrCreate(['name' => 'Tag 2']);
     $this->assertSame(2, Tag::count());
     $tag1->merge($tag2);
     $this->assertSame(1, Tag::count());
     $this->assertSame('Tag 1', Tag::first()->name);
     // Merge when the other-tag has assets attached.
     $tag3 = Tag::firstOrCreate(['name' => 'Tag 3']);
     $asset = Asset::firstOrCreate(['identifier' => 'Asset 1']);
     $asset->addTags('Tag 3');
     $this->assertSame(2, Tag::count());
     $tag1->merge($tag3);
     $this->assertSame(1, Tag::count());
     $this->assertSame(1, $tag1->assets->count());
     $this->assertSame('Tag 1', $asset->tagsAsString());
     // What about when a JobList is already tagged with both tags?
     $type = new \App\Model\JobType();
     $type->save();
     $jobList = new JobList();
     $jobList->name = 'JL1';
     $jobList->type_id = $type->id;
     $jobList->save();
     $jobList->addTags('Tag 1, Tag 4, Tag 5');
     $tag4 = Tag::firstOrCreate(['name' => 'Tag 4']);
     $this->assertSame(3, Tag::count());
     $tag1->merge($tag4);
     $this->assertSame(2, Tag::count());
     $this->assertSame('Tag 1, Tag 5', $jobList->tagsAsString());
 }
Пример #3
0
 /**
  * @testdox A JobList has a list of attached Jobs.
  */
 public function jobs()
 {
     $type = new \App\Model\JobType();
     $type->save();
     $jobList = new JobList();
     $jobList->type_id = $type->id;
     $jobList->save();
     // One incomplete job.
     $job = new Job();
     $job->job_list_id = $jobList->id;
     $job->save();
     $this->assertEquals(1, $jobList->jobs->count());
     $this->assertEquals(0, $jobList->percentComplete());
     $this->assertEquals(100, $jobList->percentIncomplete());
     // Two incomplete jobs.
     $job2 = new Job();
     $job2->job_list_id = $jobList->id;
     $job2->save();
     $jobList->load('jobs');
     $this->assertEquals(2, $jobList->jobs->count());
     $this->assertEquals(0, $jobList->percentComplete());
     $this->assertEquals(100, $jobList->percentIncomplete());
     // Complete one of them.
     $job->date_resolved = '2015-09-09';
     $job->save();
     $this->assertEquals(50, $jobList->percentIncomplete());
 }
Пример #4
0
 /**
  * @testdox A Job can be marked as complete with no date or any other metadata supplied.
  * @test
  */
 public function manualCompletion()
 {
     $type = new \App\Model\JobType();
     $type->save();
     $jobList = new JobList();
     $jobList->type_id = $type->id;
     $jobList->save();
     // One incomplete job
     $job = new Job();
     $job->job_list_id = $jobList->id;
     $job->save();
     $this->assertEquals('Incomplete', $job->status());
     //$job->resolution
 }