Esempio n. 1
0
 /** @test **/
 public function it_fetches_the_carousel_images_associated_with_the_page()
 {
     $this->createComponent('pages');
     $this->createComponent('carousel', function ($component) {
         $component->string('image');
     });
     $this->insertOn('pages', ['title' => 'Landing Page']);
     $this->insertOn('carousel', ['image' => '/path/to/image1.jpg']);
     $this->insertOn('carousel', ['image' => '/path/to/image2.jpg']);
     $this->insertOn('carousel', ['image' => '/path/to/image3.jpg']);
     Page::first()->usesMany(Carousel::class);
     Carousel::get()->each(function ($carousel) {
         $carousel->registerTo(Page::first());
     });
     $carousel = Page::first()->carousel;
     $this->assertEquals('/path/to/image1.jpg', $carousel[0]->image);
     $this->assertEquals('/path/to/image2.jpg', $carousel[1]->image);
     $this->assertEquals('/path/to/image3.jpg', $carousel[2]->image);
 }