mirror of
https://github.com/nullthoughts/laravel-data-sync.git
synced 2026-02-23 22:56:40 +00:00
fixes all tests
This commit is contained in:
@@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
namespace nullthoughts\LaravelDataSync;
|
namespace nullthoughts\LaravelDataSync;
|
||||||
|
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Facades\File;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use nullthoughts\LaravelDataSync\Exceptions\ErrorUpdatingModelException;
|
use nullthoughts\LaravelDataSync\Exceptions\ErrorUpdatingModelException;
|
||||||
use nullthoughts\LaravelDataSync\Exceptions\FileDirectoryNotFoundException;
|
use nullthoughts\LaravelDataSync\Exceptions\FileDirectoryNotFoundException;
|
||||||
use nullthoughts\LaravelDataSync\Exceptions\NoCriteriaException;
|
use nullthoughts\LaravelDataSync\Exceptions\NoCriteriaException;
|
||||||
use nullthoughts\LaravelDataSync\Exceptions\NoRecordsInvalidJSONException;
|
use nullthoughts\LaravelDataSync\Exceptions\NoRecordsInvalidJSONException;
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Illuminate\Support\Facades\File;
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use stdClass;
|
use stdClass;
|
||||||
|
|
||||||
class Updater
|
class Updater
|
||||||
@@ -116,7 +116,7 @@ class Updater
|
|||||||
{
|
{
|
||||||
$directory = $path ?? config('data-sync.path', base_path('sync'));
|
$directory = $path ?? config('data-sync.path', base_path('sync'));
|
||||||
|
|
||||||
if (!file_exists($directory) && !$this->remote) {
|
if ($this->directoryMissingLocally($directory) || $this->directoryMissingRemotely($directory)) {
|
||||||
throw new FileDirectoryNotFoundException();
|
throw new FileDirectoryNotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,4 +309,24 @@ class Updater
|
|||||||
return [$key => $value];
|
return [$key => $value];
|
||||||
})->toArray();
|
})->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Illuminate\Config\Repository $directory
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function directoryMissingLocally($directory)
|
||||||
|
{
|
||||||
|
return !$this->remote && !file_exists($directory);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Illuminate\Config\Repository $directory
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function directoryMissingRemotely($directory)
|
||||||
|
{
|
||||||
|
return $this->remote && !Storage::disk($this->disk)->exists($directory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,20 +79,20 @@ class UpdaterRemoteTest extends TestCase
|
|||||||
$this->assertTrue($supervisor->is(Roles::first()->supervisor));
|
$this->assertTrue($supervisor->is(Roles::first()->supervisor));
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * @test
|
* @test
|
||||||
// * @group current
|
* @group current
|
||||||
// */
|
*/
|
||||||
// public function exception_is_thrown_if_the_directory_does_not_exists()
|
public function exception_is_thrown_if_the_directory_does_not_exists()
|
||||||
// {
|
{
|
||||||
// try {
|
try {
|
||||||
// new UpdaterFake(null, null, true, 's3');
|
new UpdaterFake(null, null, true, 's3');
|
||||||
//
|
|
||||||
// $this->fail('exception was thrown');
|
$this->fail('exception was thrown');
|
||||||
// } catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// $this->assertEquals('Specified sync file directory does not exist', $e->getMessage());
|
$this->assertEquals('Specified sync file directory does not exist', $e->getMessage());
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
/** @test */
|
/** @test */
|
||||||
public function invalid_json_throws_an_exception()
|
public function invalid_json_throws_an_exception()
|
||||||
|
|||||||
Reference in New Issue
Block a user