mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 18:44:03 +00:00
Improve HTTP tests with custom assertion method
This commit is contained in:
parent
f328fc9c08
commit
cb2bd018aa
2 changed files with 12 additions and 3 deletions
|
|
@ -4,7 +4,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Stancl\Tenancy\Tests;
|
namespace Stancl\Tenancy\Tests;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Redis;
|
use Illuminate\Testing\Assert as PHPUnit;
|
||||||
|
use Illuminate\Testing\TestResponse;
|
||||||
use Stancl\Tenancy\Tenant;
|
use Stancl\Tenancy\Tenant;
|
||||||
|
|
||||||
abstract class TestCase extends \Orchestra\Testbench\TestCase
|
abstract class TestCase extends \Orchestra\Testbench\TestCase
|
||||||
|
|
@ -37,6 +38,14 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
|
||||||
if ($this->autoInitTenancy) {
|
if ($this->autoInitTenancy) {
|
||||||
$this->initTenancy();
|
$this->initTenancy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TestResponse::macro('assertContent', function ($content) {
|
||||||
|
/** @var TestResponse $this */
|
||||||
|
|
||||||
|
PHPUnit::assertSame($content, $this->baseResponse->getContent());
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createTenant($domains = ['test.localhost'])
|
public function createTenant($domains = ['test.localhost'])
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ class PathIdentificationTest extends TestCase
|
||||||
|
|
||||||
$this
|
$this
|
||||||
->get('/acme/foo/abc/xyz')
|
->get('/acme/foo/abc/xyz')
|
||||||
->assertSee('abc + xyz');
|
->assertContent('abc + xyz');
|
||||||
|
|
||||||
$this->assertTrue(tenancy()->initialized);
|
$this->assertTrue(tenancy()->initialized);
|
||||||
$this->assertSame('acme', tenant('id'));
|
$this->assertSame('acme', tenant('id'));
|
||||||
|
|
@ -77,6 +77,6 @@ class PathIdentificationTest extends TestCase
|
||||||
|
|
||||||
$this
|
$this
|
||||||
->get('/acme/foo/abc/xyz')
|
->get('/acme/foo/abc/xyz')
|
||||||
->assertSee('foo');
|
->assertContent('foo');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue