Skip to content

Instantly share code, notes, and snippets.

@jsdecena
Created March 8, 2018 00:24
Show Gist options
  • Save jsdecena/a43e25bd433f8e3f57675b814e4c77ca to your computer and use it in GitHub Desktop.
Save jsdecena/a43e25bd433f8e3f57675b814e4c77ca to your computer and use it in GitHub Desktop.
Carousel Unit Test
<?php
namespace Tests\Unit\Carousels;
use Tests\TestCase;
class CarouselUnitTest extends TestCase
{
/** @test */
public function it_can_show_the_carousel()
{
$carousel = factory(Carousel::class)->create();
$carouselRepo = new CarouselRepository(new Carousel);
$found = $carouselRepo->findCarousel($carousel->id);
$this->assertInstanceOf(Carousel::class, $found);
$this->assertEquals($found->title, $carousel->title);
$this->assertEquals($found->link, $carousel->link);
$this->assertEquals($found->src, $carousel->src);
}
/** @test */
public function it_can_create_a_carousel()
{
$data = [
'title' => $this->faker->word,
'link' => $this->faker->url,
'src' => $this->faker->url,
];
$carouselRepo = new CarouselRepository(new Carousel);
$carousel = $carouselRepo->createCarousel($data);
$this->assertInstanceOf(Carousel::class, $carousel);
$this->assertEquals($data['title'], $carousel->title);
$this->assertEquals($data['link'], $carousel->link);
$this->assertEquals($data['src'], $carousel->src);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment