mirror of
https://github.com/nullthoughts/laravel-data-sync.git
synced 2026-01-26 03:34:02 +00:00
wip tests
This commit is contained in:
10
tests/Roles.php
Normal file
10
tests/Roles.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace distinctm\LaravelDataSync\Tests;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Roles extends Model
|
||||
{
|
||||
|
||||
}
|
||||
15
tests/TestCase.php
Normal file
15
tests/TestCase.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace distinctm\LaravelDataSync\Tests;
|
||||
|
||||
class TestCase extends \Orchestra\Testbench\TestCase
|
||||
{
|
||||
protected function getEnvironmentSetUp($app)
|
||||
{
|
||||
$app['config']->set('database.default', 'testdb');
|
||||
$app['config']->set('database.connections.testdb', [
|
||||
'driver' => 'sqlite',
|
||||
'database' => ':memory:'
|
||||
]);
|
||||
}
|
||||
}
|
||||
36
tests/Unit/UpdaterTest.php
Normal file
36
tests/Unit/UpdaterTest.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace distinctm\LaravelDataSync\Tests;
|
||||
|
||||
use distinctm\LaravelDataSync\Updater;
|
||||
|
||||
class UpdaterTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
public function exception_is_thrown_if_the_directory_does_not_exists()
|
||||
{
|
||||
$this->expectException(\Exception::class);
|
||||
|
||||
new Updater();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function experiment()
|
||||
{
|
||||
$updater = new UpdaterFake(__DIR__ . '/../test-data', 'roles');
|
||||
|
||||
\DB::enableQueryLog();
|
||||
$updater->run();
|
||||
\DB::disableQueryLog();
|
||||
|
||||
dd(\DB::getQueryLog());
|
||||
}
|
||||
}
|
||||
|
||||
class UpdaterFake extends Updater
|
||||
{
|
||||
protected function getModel(string $name)
|
||||
{
|
||||
return Roles::class;
|
||||
}
|
||||
}
|
||||
11
tests/test-data/roles.json
Normal file
11
tests/test-data/roles.json
Normal file
@@ -0,0 +1,11 @@
|
||||
[
|
||||
{
|
||||
"_slug": "update-student-records"
|
||||
},
|
||||
{
|
||||
"_slug": "borrow-ferrari"
|
||||
},
|
||||
{
|
||||
"_slug": "destroy-ferrari"
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user