mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 19:04:02 +00:00
Extract VirtualColumn package
This commit is contained in:
parent
b362c16f89
commit
f483d0b8cf
3 changed files with 6 additions and 164 deletions
|
|
@ -50,44 +50,6 @@ class TenantModelTest extends TestCase
|
|||
$this->assertSame(null, app(Contracts\Tenant::class));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function keys_which_dont_have_their_own_column_go_into_data_json_column()
|
||||
{
|
||||
$tenant = Tenant::create([
|
||||
'foo' => 'bar',
|
||||
]);
|
||||
|
||||
// Test that model works correctly
|
||||
$this->assertSame('bar', $tenant->foo);
|
||||
$this->assertSame(null, $tenant->data);
|
||||
|
||||
// Low level test to assert database structure
|
||||
$this->assertSame(['foo' => 'bar'], json_decode(DB::table('tenants')->where('id', $tenant->id)->first()->data, true));
|
||||
$this->assertSame(null, DB::table('tenants')->where('id', $tenant->id)->first()->foo ?? null);
|
||||
|
||||
// Model has the correct structure when retrieved
|
||||
$tenant = Tenant::first();
|
||||
$this->assertSame('bar', $tenant->foo);
|
||||
$this->assertSame(null, $tenant->data);
|
||||
|
||||
// Model can be updated
|
||||
$tenant->update([
|
||||
'foo' => 'baz',
|
||||
'abc' => 'xyz',
|
||||
]);
|
||||
|
||||
$this->assertSame('baz', $tenant->foo);
|
||||
$this->assertSame('xyz', $tenant->abc);
|
||||
$this->assertSame(null, $tenant->data);
|
||||
|
||||
// Model can be retrieved after update & is structure correctly
|
||||
$tenant = Tenant::first();
|
||||
|
||||
$this->assertSame('baz', $tenant->foo);
|
||||
$this->assertSame('xyz', $tenant->abc);
|
||||
$this->assertSame(null, $tenant->data);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function id_is_generated_when_no_id_is_supplied()
|
||||
{
|
||||
|
|
@ -170,12 +132,6 @@ class TenantModelTest extends TestCase
|
|||
$this->assertSame(2, Tenant::count());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function data_is_never_encoded_or_decoded_twice()
|
||||
{
|
||||
// todo. tests for registerPriorityListener
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function the_model_uses_TenantCollection()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue