mirror of
https://github.com/nullthoughts/laravel-data-sync.git
synced 2026-02-16 18:54:02 +00:00
Filters for JSON files, closes #8
This commit is contained in:
@@ -106,9 +106,12 @@ class Updater
|
|||||||
return Collection::wrap($directory . '/' . $model . '.json');
|
return Collection::wrap($directory . '/' . $model . '.json');
|
||||||
}
|
}
|
||||||
|
|
||||||
return collect(File::files($directory))->map(function ($path) {
|
return collect(File::files($directory))
|
||||||
return $path->getPathname();
|
->filter(function($file) {
|
||||||
});
|
return pathinfo($file, PATHINFO_EXTENSION) == 'json';
|
||||||
|
})->map(function ($path) {
|
||||||
|
return $path->getPathname();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -131,4 +131,13 @@ class UpdaterTest extends TestCase
|
|||||||
$updater = new UpdaterFake(__DIR__ . '/../test-data/ordered');
|
$updater = new UpdaterFake(__DIR__ . '/../test-data/ordered');
|
||||||
$updater->run();
|
$updater->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @test */
|
||||||
|
public function it_ignores_non_json_files()
|
||||||
|
{
|
||||||
|
$updater = new UpdaterFake(__DIR__ . '/../test-data/not-json');
|
||||||
|
$updater->run();
|
||||||
|
|
||||||
|
$this->assertDatabaseMissing('roles', ['slug' => 'update-student-records']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
9
tests/test-data/not-json/roles.txt
Normal file
9
tests/test-data/not-json/roles.txt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"_slug": "update-student-records",
|
||||||
|
"category": "testing",
|
||||||
|
"supervisor": {
|
||||||
|
"name": "CEO"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
Reference in New Issue
Block a user