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

Improve PHPUnit assertions

This commit is contained in:
peter279k 2020-11-29 02:13:52 +08:00
parent 126afcd0dd
commit ce0dee4343
5 changed files with 12 additions and 12 deletions

View file

@ -45,7 +45,7 @@ class AutomaticModeTest extends TestCase
tenancy()->end(); tenancy()->end();
$this->assertSame(true, app('tenancy_ended')); $this->assertTrue(app('tenancy_ended'));
} }
/** @test */ /** @test */
@ -78,7 +78,7 @@ class AutomaticModeTest extends TestCase
tenancy()->initialize($tenant = Tenant::create()); tenancy()->initialize($tenant = Tenant::create());
tenancy()->central(function () { tenancy()->central(function () {
$this->assertSame(null, tenant()); $this->assertNull(tenant());
}); });
$this->assertSame($tenant, tenant()); $this->assertSame($tenant, tenant());

View file

@ -132,7 +132,7 @@ class BootstrapperTest extends TestCase
$this->assertSame('bar', Redis::get('foo')); $this->assertSame('bar', Redis::get('foo'));
tenancy()->initialize($tenant2); tenancy()->initialize($tenant2);
$this->assertSame(null, Redis::get('foo')); $this->assertNull(Redis::get('foo'));
Redis::set('foo', 'xyz'); Redis::set('foo', 'xyz');
Redis::set('abc', 'def'); Redis::set('abc', 'def');
$this->assertSame('xyz', Redis::get('foo')); $this->assertSame('xyz', Redis::get('foo'));
@ -140,12 +140,12 @@ class BootstrapperTest extends TestCase
tenancy()->initialize($tenant1); tenancy()->initialize($tenant1);
$this->assertSame('bar', Redis::get('foo')); $this->assertSame('bar', Redis::get('foo'));
$this->assertSame(null, Redis::get('abc')); $this->assertNull(Redis::get('abc'));
$tenant3 = Tenant::create(); $tenant3 = Tenant::create();
tenancy()->initialize($tenant3); tenancy()->initialize($tenant3);
$this->assertSame(null, Redis::get('foo')); $this->assertNull(Redis::get('foo'));
$this->assertSame(null, Redis::get('abc')); $this->assertNull(Redis::get('abc'));
} }
/** @test */ /** @test */

View file

@ -62,7 +62,7 @@ class EventListenerTest extends TestCase
return false; return false;
}); });
$this->assertSame(false, Tenant::create()->exists); $this->assertFalse(Tenant::create()->exists);
$this->assertSame(0, Tenant::count()); $this->assertSame(0, Tenant::count());
} }

View file

@ -25,7 +25,7 @@ class TenantConfigTest extends TestCase
/** @test */ /** @test */
public function config_is_merged_and_removed() public function config_is_merged_and_removed()
{ {
$this->assertSame(null, config('services.paypal')); $this->assertNull(config('services.paypal'));
config([ config([
'tenancy.features' => [TenantConfig::class], 'tenancy.features' => [TenantConfig::class],
'tenancy.bootstrappers' => [], 'tenancy.bootstrappers' => [],
@ -56,7 +56,7 @@ class TenantConfigTest extends TestCase
/** @test */ /** @test */
public function the_value_can_be_set_to_multiple_config_keys() public function the_value_can_be_set_to_multiple_config_keys()
{ {
$this->assertSame(null, config('services.paypal')); $this->assertNull(config('services.paypal'));
config([ config([
'tenancy.features' => [TenantConfig::class], 'tenancy.features' => [TenantConfig::class],
'tenancy.bootstrappers' => [], 'tenancy.bootstrappers' => [],

View file

@ -30,7 +30,7 @@ class GlobalCacheTest extends TestCase
/** @test */ /** @test */
public function global_cache_manager_stores_data_in_global_cache() public function global_cache_manager_stores_data_in_global_cache()
{ {
$this->assertSame(null, cache('foo')); $this->assertNull(cache('foo'));
GlobalCache::put(['foo' => 'bar'], 1); GlobalCache::put(['foo' => 'bar'], 1);
$this->assertSame('bar', GlobalCache::get('foo')); $this->assertSame('bar', GlobalCache::get('foo'));
@ -45,13 +45,13 @@ class GlobalCacheTest extends TestCase
tenancy()->end(); tenancy()->end();
$this->assertSame('xyz', GlobalCache::get('abc')); $this->assertSame('xyz', GlobalCache::get('abc'));
$this->assertSame('bar', GlobalCache::get('foo')); $this->assertSame('bar', GlobalCache::get('foo'));
$this->assertSame(null, cache('def')); $this->assertNull(cache('def'));
$tenant2 = Tenant::create(); $tenant2 = Tenant::create();
tenancy()->initialize($tenant2); tenancy()->initialize($tenant2);
$this->assertSame('xyz', GlobalCache::get('abc')); $this->assertSame('xyz', GlobalCache::get('abc'));
$this->assertSame('bar', GlobalCache::get('foo')); $this->assertSame('bar', GlobalCache::get('foo'));
$this->assertSame(null, cache('def')); $this->assertNull(cache('def'));
cache(['def' => 'xxx'], 1); cache(['def' => 'xxx'], 1);
$this->assertSame('xxx', cache('def')); $this->assertSame('xxx', cache('def'));