1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 15:14:04 +00:00

removed uses from individual files and add it in Pest

This commit is contained in:
Abrar Ahmad 2022-06-30 13:12:34 +05:00
parent e7d0bbf302
commit 8bd7c95fff
26 changed files with 2 additions and 91 deletions

View file

@ -10,8 +10,6 @@ use Stancl\Tenancy\Listeners\BootstrapTenancy;
use Stancl\Tenancy\Listeners\RevertToCentralContext;
use Stancl\Tenancy\Tests\Etc\Tenant;
uses(Stancl\Tenancy\Tests\TestCase::class);
beforeEach(function () {
Event::listen(TenancyInitialized::class, BootstrapTenancy::class);
Event::listen(TenancyEnded::class, RevertToCentralContext::class);

View file

@ -22,8 +22,6 @@ use Stancl\Tenancy\Bootstrappers\RedisTenancyBootstrapper;
use Stancl\Tenancy\Bootstrappers\DatabaseTenancyBootstrapper;
use Stancl\Tenancy\Bootstrappers\FilesystemTenancyBootstrapper;
uses(Stancl\Tenancy\Tests\TestCase::class);
beforeEach(function () {
Event::listen(
TenantCreated::class,

View file

@ -8,8 +8,6 @@ use Stancl\Tenancy\Events\TenancyInitialized;
use Stancl\Tenancy\Listeners\BootstrapTenancy;
use Stancl\Tenancy\Tests\Etc\Tenant;
uses(Stancl\Tenancy\Tests\TestCase::class);
beforeEach(function () {
config(['tenancy.bootstrappers' => [
CacheTenancyBootstrapper::class,

View file

@ -6,8 +6,6 @@ use Illuminate\Support\Facades\DB;
use Stancl\Tenancy\Resolvers\DomainTenantResolver;
use Stancl\Tenancy\Tests\Etc\Tenant;
uses(Stancl\Tenancy\Tests\TestCase::class);
afterEach(function () {
DomainTenantResolver::$shouldCache = false;
});

View file

@ -7,8 +7,6 @@ use Stancl\Tenancy\Database\Concerns\HasDomains;
use Stancl\Tenancy\Middleware\InitializeTenancyByDomainOrSubdomain;
use Stancl\Tenancy\Database\Models;
uses(Stancl\Tenancy\Tests\TestCase::class);
beforeEach(function () {
Route::group([
'middleware' => InitializeTenancyByDomainOrSubdomain::class,

View file

@ -17,8 +17,6 @@ use Stancl\Tenancy\Listeners\RevertToCentralContext;
use Stancl\Tenancy\Tests\Etc\ExampleSeeder;
use Stancl\Tenancy\Tests\Etc\Tenant;
uses(Stancl\Tenancy\Tests\TestCase::class);
beforeEach(function () {
Event::listen(TenantCreated::class, JobPipeline::make([CreateDatabase::class])->send(function (TenantCreated $event) {
return $event->tenant;

View file

@ -14,8 +14,6 @@ use Stancl\Tenancy\Tests\Etc\Tenant;
use Illuminate\Foundation\Auth\User as Authenticable;
use Stancl\Tenancy\Tests\Etc\TestSeeder;
uses(Stancl\Tenancy\Tests\TestCase::class);
test('database can be created after tenant creation', function () {
config(['tenancy.database.template_tenant_connection' => 'mysql']);

View file

@ -18,8 +18,6 @@ use Stancl\Tenancy\TenantDatabaseManagers\MySQLDatabaseManager;
use Stancl\Tenancy\TenantDatabaseManagers\PermissionControlledMySQLDatabaseManager;
use Stancl\Tenancy\Tests\Etc\Tenant;
uses(Stancl\Tenancy\Tests\TestCase::class);
beforeEach(function () {
config([
'tenancy.database.managers.mysql' => PermissionControlledMySQLDatabaseManager::class,

View file

@ -11,8 +11,6 @@ use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedOnDomainException;
use Stancl\Tenancy\Middleware\InitializeTenancyByDomain;
use Stancl\Tenancy\Resolvers\DomainTenantResolver;
uses(Stancl\Tenancy\Tests\TestCase::class);
beforeEach(function () {
Route::group([
'middleware' => InitializeTenancyByDomain::class,

View file

@ -20,8 +20,6 @@ use Stancl\Tenancy\Listeners\BootstrapTenancy;
use Stancl\Tenancy\Listeners\QueueableListener;
use Stancl\Tenancy\Tests\Etc\Tenant;
uses(Stancl\Tenancy\Tests\TestCase::class);
test('listeners can be synchronous', function () {
Queue::fake();
Event::listen(TenantCreated::class, FooListener::class);

View file

@ -11,8 +11,6 @@ use Stancl\Tenancy\Listeners\BootstrapTenancy;
use Stancl\Tenancy\Listeners\RevertToCentralContext;
use Stancl\Tenancy\Tests\Etc\Tenant;
uses(Stancl\Tenancy\Tests\TestCase::class);
beforeEach(function () {
config(['tenancy.bootstrappers' => [
CacheTenancyBootstrapper::class,

View file

@ -9,8 +9,6 @@ use Stancl\Tenancy\Middleware\CheckTenantForMaintenanceMode;
use Stancl\Tenancy\Middleware\InitializeTenancyByDomain;
use Stancl\Tenancy\Tests\Etc\Tenant;
uses(Stancl\Tenancy\Tests\TestCase::class);
test('tenant can be in maintenance mode', function () {
Route::get('/foo', function () {
return 'bar';

View file

@ -9,8 +9,6 @@ use Stancl\Tenancy\Middleware\InitializeTenancyByPath;
use Stancl\Tenancy\Resolvers\PathTenantResolver;
use Stancl\Tenancy\Tests\Etc\Tenant;
uses(Stancl\Tenancy\Tests\TestCase::class);
beforeEach(function () {
PathTenantResolver::$tenantParameterName = 'tenant';

View file

@ -1,42 +1,3 @@
<?php
uses(\Stancl\Tenancy\Tests\TestCase::class)->in('Etc', 'Features');
/*
|--------------------------------------------------------------------------
| Test Case
|--------------------------------------------------------------------------
|
| The closure you provide to your test functions is always bound to a specific PHPUnit test
| case class. By default, that class is "PHPUnit\Framework\TestCase". Of course, you may
| need to change it using the "uses()" function to bind a different classes or traits.
|
*/
/** @link https://pestphp.com/docs/underlying-test-case */
/*
|--------------------------------------------------------------------------
| Expectations
|--------------------------------------------------------------------------
|
| When you're writing tests, you often need to check that values meet certain conditions. The
| "expect()" function gives you access to a set of "expectations" methods that you can use
| to assert different things. Of course, you may extend the Expectation API at any time.
|
*/
/** @link https://pestphp.com/docs/expectations#custom-expectations */
/*
|--------------------------------------------------------------------------
| Functions
|--------------------------------------------------------------------------
|
| While Pest is very powerful out-of-the-box, you may have some testing code specific to your
| project that you don't want to repeat in every file. Here you can also expose helpers as
| global functions to help you to reduce the number of lines of code in your test files.
|
*/
/** @link https://pestphp.com/docs/helpers */
uses(Stancl\Tenancy\Tests\TestCase::class)->in(__DIR__);

View file

@ -27,8 +27,6 @@ use Stancl\Tenancy\Listeners\RevertToCentralContext;
use Stancl\Tenancy\Bootstrappers\QueueTenancyBootstrapper;
use Stancl\Tenancy\Bootstrappers\DatabaseTenancyBootstrapper;
uses(Stancl\Tenancy\Tests\TestCase::class);
beforeEach(function () {
config([
'tenancy.bootstrappers' => [

View file

@ -6,8 +6,6 @@ use Illuminate\Support\Facades\Route;
use Stancl\Tenancy\Middleware\InitializeTenancyByRequestData;
use Stancl\Tenancy\Tests\Etc\Tenant;
uses(Stancl\Tenancy\Tests\TestCase::class);
beforeEach(function () {
config([
'tenancy.central_domains' => [

View file

@ -28,8 +28,6 @@ use Stancl\Tenancy\Listeners\RevertToCentralContext;
use Stancl\Tenancy\Listeners\UpdateSyncedResource;
use Stancl\Tenancy\Tests\Etc\Tenant;
uses(Stancl\Tenancy\Tests\TestCase::class);
beforeEach(function () {
config(['tenancy.bootstrappers' => [
DatabaseTenancyBootstrapper::class,

View file

@ -11,8 +11,6 @@ use Stancl\Tenancy\Middleware\InitializeTenancyBySubdomain;
use Stancl\Tenancy\Middleware\ScopeSessions;
use Stancl\Tenancy\Tests\Etc\Tenant;
uses(Stancl\Tenancy\Tests\TestCase::class);
beforeEach(function () {
Route::group([
'middleware' => [StartSession::class, InitializeTenancyBySubdomain::class, ScopeSessions::class],

View file

@ -12,8 +12,6 @@ use Stancl\Tenancy\Database\Concerns\BelongsToTenant;
use Stancl\Tenancy\Database\Concerns\HasScopedValidationRules;
use Stancl\Tenancy\Tests\Etc\Tenant as TestTenant;
uses(Stancl\Tenancy\Tests\TestCase::class);
beforeEach(function () {
BelongsToTenant::$tenantIdColumn = 'tenant_id';

View file

@ -8,8 +8,6 @@ use Stancl\Tenancy\Exceptions\NotASubdomainException;
use Stancl\Tenancy\Middleware\InitializeTenancyBySubdomain;
use Stancl\Tenancy\Database\Models;
uses(Stancl\Tenancy\Tests\TestCase::class);
beforeEach(function () {
// Global state cleanup after some tests
InitializeTenancyBySubdomain::$onFail = null;

View file

@ -13,8 +13,6 @@ use Stancl\Tenancy\Middleware\InitializeTenancyByDomain;
use Stancl\Tenancy\Middleware\InitializeTenancyByRequestData;
use Stancl\Tenancy\Tests\Etc\Tenant;
uses(Stancl\Tenancy\Tests\TestCase::class);
beforeEach(function () {
config(['tenancy.bootstrappers' => [
FilesystemTenancyBootstrapper::class,

View file

@ -6,8 +6,6 @@ use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\DB;
use Stancl\Tenancy\Tests\Etc\Tenant;
uses(Stancl\Tenancy\Tests\TestCase::class);
test('commands run globally are tenant aware and return valid exit code', function () {
$tenant1 = Tenant::create();
$tenant2 = Tenant::create();

View file

@ -24,8 +24,6 @@ use Stancl\Tenancy\TenantDatabaseManagers\PostgreSQLSchemaManager;
use Stancl\Tenancy\TenantDatabaseManagers\SQLiteDatabaseManager;
use Stancl\Tenancy\Tests\Etc\Tenant;
uses(Stancl\Tenancy\Tests\TestCase::class);
test('databases can be created and deleted', function ($driver, $databaseManager) {
Event::listen(TenantCreated::class, JobPipeline::make([CreateDatabase::class])->send(function (TenantCreated $event) {
return $event->tenant;

View file

@ -19,8 +19,6 @@ use Stancl\Tenancy\Listeners\BootstrapTenancy;
use Stancl\Tenancy\Tests\Etc\Tenant;
use Stancl\Tenancy\UUIDGenerator;
uses(Stancl\Tenancy\Tests\TestCase::class);
test('created event is dispatched', function () {
Event::fake([TenantCreated::class]);

View file

@ -24,8 +24,6 @@ use Stancl\Tenancy\Middleware\InitializeTenancyByPath;
use Stancl\Tenancy\Tests\Etc\Tenant;
use Illuminate\Foundation\Auth\User as Authenticable;
uses(Stancl\Tenancy\Tests\TestCase::class);
beforeEach(function () {
$this->artisan('migrate', [
'--path' => __DIR__ . '/../assets/impersonation-migrations',

View file

@ -7,8 +7,6 @@ use Stancl\Tenancy\Features\UniversalRoutes;
use Stancl\Tenancy\Middleware\InitializeTenancyByDomain;
use Stancl\Tenancy\Tests\Etc\Tenant;
uses(Stancl\Tenancy\Tests\TestCase::class);
afterEach(function () {
InitializeTenancyByDomain::$onFail = null;
});
@ -67,7 +65,7 @@ test('making one route universal doesnt make all routes universal', function ()
$this->get('http://acme.localhost/foo')
->assertSuccessful()
->assertSee('Tenancy is initialized.');
tenancy()->end();
$this->get('http://localhost/bar')