Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/model/src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public static function migrate(?string $locale = null): void

$data = collect(Repository::fetchData(static::class, $locale));

$schema = collect(str_getcsv($data->first()));
$schema = collect(str_getcsv($data->first(), escape: '\\'));

$data->transform(function (string $line) use ($schema): Collection {
return $schema->combine(
Expand Down
27 changes: 27 additions & 0 deletions tests/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,33 @@ protected function testModel(string $model): void
}
}

public function test_can_migrate_models_without_php_deprecations(): void
{
Repository::registerSource(Models\Foo::class, App::getLocale(), __DIR__ . '/data/foo-en.csv');

$deprecations = [];
$errorReporting = error_reporting(E_ALL);

set_error_handler(function (int $severity, string $message) use (&$deprecations): bool {
if (($severity === E_DEPRECATED) || ($severity === E_USER_DEPRECATED)) {
$deprecations[] = $message;

return true;
}

return false;
});

try {
Models\Foo::cache([App::getLocale()]);
} finally {
restore_error_handler();
error_reporting($errorReporting);
}

$this->assertSame([], $deprecations);
}

public function test_can_translate_models(): void
{
Repository::registerSource(Models\Foo::class, 'en', __DIR__ . '/data/foo-en.csv');
Expand Down