Files
ticketbeast/tests/TestCase.php
2017-12-08 12:29:13 -05:00

49 lines
1.4 KiB
PHP

<?php
namespace Tests;
use Exception;
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
{
use CreatesApplication;
/**
* The base URL to use while testing the application.
*
* @var string
*/
protected $baseUrl = 'http://localhost';
protected function setUp()
{
parent::setUp();
TestResponse::macro('data', function ($key) {
return $this->original->getData()[$key];
});
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));
});
});
}
}