This repository has been archived by the owner on Oct 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Casts array is now supported. Tests with database.
- Loading branch information
Showing
13 changed files
with
179 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 8 additions & 2 deletions
10
tests/NestedCustomerUser.php → tests/Models/NestedCustomerUser.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,55 @@ | ||
<?php | ||
|
||
|
||
namespace Biscofil\LaravelSubmodels\Test; | ||
namespace Biscofil\LaravelSubmodels\Tests; | ||
|
||
use Illuminate\Foundation\Application; | ||
use Illuminate\Support\Facades\Schema; | ||
use Orchestra\Testbench\TestCase as OrchestraTestCase; | ||
|
||
class TestCase extends OrchestraTestCase | ||
{ | ||
/** | ||
* | ||
*/ | ||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
$this->runMigrations(); | ||
$this->withFactories(__DIR__ . '/factories'); | ||
} | ||
|
||
/** | ||
* @param Application $app | ||
*/ | ||
protected function getEnvironmentSetUp($app) | ||
{ | ||
// Setup default database to use sqlite :memory: | ||
$app['config']->set('database.default', 'testbench'); | ||
$app['config']->set('database.connections.testbench', [ | ||
'driver' => 'sqlite', | ||
'database' => ':memory:', | ||
'prefix' => '', | ||
]); | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
public function runMigrations() | ||
{ | ||
Schema::create('users', function ($table) { | ||
$table->increments('id'); | ||
|
||
$table->boolean('is_admin')->default(false); | ||
$table->string('admin_name')->nullable(); | ||
|
||
$table->string('customer_name')->nullable(); | ||
|
||
$table->boolean('is_nested_customer')->default(false);; | ||
$table->string('nested_customer_name')->nullable(); | ||
}); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
use Biscofil\LaravelSubmodels\Tests\Models\AdminUser; | ||
|
||
$factory->define(AdminUser::class, function () { | ||
return [ | ||
'is_admin' => true, | ||
'admin_name' => 'foo', | ||
]; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
|
||
use Biscofil\LaravelSubmodels\Tests\Models\CustomerUser; | ||
|
||
$factory->define(CustomerUser::class, function () { | ||
return [ | ||
'is_admin' => false, | ||
'customer_name' => 'demo', | ||
'is_nested_customer' => false, | ||
]; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
|
||
use Biscofil\LaravelSubmodels\Tests\Models\NestedCustomerUser; | ||
|
||
$factory->define(NestedCustomerUser::class, function () { | ||
return [ | ||
'is_admin' => false, | ||
'customer_name' => 'demo nested', | ||
'is_nested_customer' => true, | ||
'nested_customer_name' => 'foo', | ||
]; | ||
}); |