/** @test */
 public function it_assigns_files_to_event()
 {
     $dbEventRepository = new DbEventRepository();
     $event = factory(Event::class)->create();
     $expectedFile = factory(File::class)->create();
     $this->assertCount(0, $event->files);
     $event = $dbEventRepository->assignFiles($event, [$expectedFile]);
     $this->assertCount(1, $event->files()->get());
     $this->assertSame($event->files()->get()->get(0)->name, $expectedFile->name);
     $expectedFile = factory(File::class)->create();
     $expectedFile1 = factory(File::class)->create();
     $event = $dbEventRepository->assignFiles($event, [$expectedFile, $expectedFile1]);
     $this->assertCount(3, $event->files()->get());
     $this->assertSame($event->files()->get()->get(2)->name, $expectedFile1->name);
 }
Beispiel #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $dbCompanyRepository = new DbCompanyRepository();
     $dbEventRepository = new DbEventRepository();
     $dbDecisionRepository = new DbDecisionRepository();
     foreach ($dbCompanyRepository->all() as $event) {
         $files = factory(File::class, 2)->create();
         $dbCompanyRepository->assignFiles($event, $files);
     }
     foreach ($dbEventRepository->all() as $event) {
         $files = factory(File::class, 2)->create();
         $dbEventRepository->assignFiles($event, $files);
     }
     foreach ($dbDecisionRepository->all() as $decision) {
         $file = factory(File::class)->create();
         $dbDecisionRepository->assignFile($decision, $file);
     }
 }