Skip to content

Instantly share code, notes, and snippets.

@jsdecena
Created March 8, 2018 01:06
Show Gist options
  • Save jsdecena/4d5c5fe005ce63d027bc049c724aa7e2 to your computer and use it in GitHub Desktop.
Save jsdecena/4d5c5fe005ce63d027bc049c724aa7e2 to your computer and use it in GitHub Desktop.
Carousel Unit Test File
<?php
namespace Tests\Unit\Carousels;
use Tests\TestCase;
class CarouselUnitTest extends TestCase
{
/** @test */
public function it_should_throw_update_error_exception_when_the_carousel_has_failed_to_update()
{
$this->expectException(UpdateCarouselErrorException::class);
$carousel = factory(Carousel::class)->create();
$carouselRepo = new CarouselRepository($carousel);
$data = ['title' => null];
$carouselRepo->updateCarousel($data);
}
/** @test */
public function it_should_throw_not_found_error_exception_when_the_carousel_is_not_found()
{
$this->expectException(CarouselNotFoundException::class);
$carouselRepo = new CarouselRepository(new Carousel);
$carouselRepo->findCarousel(999);
}
/** @test */
public function it_should_throw_an_error_when_the_required_columns_are_not_filled()
{
$this->expectException(CreateCarouselErrorException::class);
$carouselRepo = new CarouselRepository(new Carousel);
$carouselRepo->createCarousel([]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment