131 - Asserting Against Sort Order

This commit is contained in:
Adam Wathan
2017-08-16 14:30:07 -04:00
parent 8893f5b03a
commit ac6c420170
5 changed files with 56 additions and 29 deletions

View File

@@ -7,6 +7,7 @@ use App\Exceptions\Handler;
use PHPUnit\Framework\Assert;
use Illuminate\Foundation\Testing\TestResponse;
use Illuminate\Contracts\Debug\ExceptionHandler;
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
abstract class TestCase extends \Illuminate\Foundation\Testing\TestCase
{
@@ -30,6 +31,23 @@ abstract class TestCase extends \Illuminate\Foundation\Testing\TestCase
TestResponse::macro('assertViewIs', function ($name) {
Assert::assertEquals($name, $this->original->name());
});
EloquentCollection::macro('assertContains', function ($value) {
Assert::assertTrue($this->contains($value), "Failed asserting that the collection contains the specified value.");
});
EloquentCollection::macro('assertNotContains', function ($value) {
Assert::assertFalse($this->contains($value), "Failed asserting that the collection does not contain the specified value.");
});
EloquentCollection::macro('assertEquals', function ($items) {
Assert::assertEquals(count($this), count($items));
$this->zip($items)->each(function ($pair) {
list($a, $b) = $pair;
Assert::assertTrue($a->is($b));
});
});
}
protected function disableExceptionHandling()