Skip to content

Commit 02867f5

Browse files
committed
wip tests
1 parent 6a0932a commit 02867f5

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed

tests/Roles.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace distinctm\LaravelDataSync\Tests;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class Roles extends Model
8+
{
9+
10+
}

tests/TestCase.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace distinctm\LaravelDataSync\Tests;
4+
5+
class TestCase extends \Orchestra\Testbench\TestCase
6+
{
7+
protected function getEnvironmentSetUp($app)
8+
{
9+
$app['config']->set('database.default', 'testdb');
10+
$app['config']->set('database.connections.testdb', [
11+
'driver' => 'sqlite',
12+
'database' => ':memory:'
13+
]);
14+
}
15+
}

tests/Unit/UpdaterTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace distinctm\LaravelDataSync\Tests;
4+
5+
use distinctm\LaravelDataSync\Updater;
6+
7+
class UpdaterTest extends TestCase
8+
{
9+
/** @test */
10+
public function exception_is_thrown_if_the_directory_does_not_exists()
11+
{
12+
$this->expectException(\Exception::class);
13+
14+
new Updater();
15+
}
16+
17+
/** @test */
18+
public function experiment()
19+
{
20+
$updater = new UpdaterFake(__DIR__ . '/../test-data', 'roles');
21+
22+
\DB::enableQueryLog();
23+
$updater->run();
24+
\DB::disableQueryLog();
25+
26+
dd(\DB::getQueryLog());
27+
}
28+
}
29+
30+
class UpdaterFake extends Updater
31+
{
32+
protected function getModel(string $name)
33+
{
34+
return Roles::class;
35+
}
36+
}

tests/test-data/roles.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[
2+
{
3+
"_slug": "update-student-records"
4+
},
5+
{
6+
"_slug": "borrow-ferrari"
7+
},
8+
{
9+
"_slug": "destroy-ferrari"
10+
}
11+
]

0 commit comments

Comments
 (0)