diff --git a/src/Entries/Entry.php b/src/Entries/Entry.php index a2ea8e1b..23b15dd0 100644 --- a/src/Entries/Entry.php +++ b/src/Entries/Entry.php @@ -127,6 +127,10 @@ public static function makeModelFromContract(EntryContract $source) 'order' => $source->order(), ]; + if ($source->template) { + $attributes['data']->put('template', $source->template); + } + foreach ($dataMappings as $key) { $attributes[$key] = $data->get($key); } diff --git a/tests/Commands/ImportEntriesTest.php b/tests/Commands/ImportEntriesTest.php index 7d0d7986..f47a4253 100644 --- a/tests/Commands/ImportEntriesTest.php +++ b/tests/Commands/ImportEntriesTest.php @@ -82,4 +82,21 @@ public function it_imports_localized_entries() $this->assertDatabaseHas('entries', ['collection' => 'pages', 'site' => 'en', 'slug' => 'foo', 'data' => '{"foo":"bar"}']); $this->assertDatabaseHas('entries', ['collection' => 'pages', 'site' => 'fr', 'slug' => 'foo', 'data' => '{"foo":"bar","baz":"qux","__localized_fields":[]}']); } + + #[Test] + public function it_imports_template_correctly() + { + $collection = tap(Collection::make('pages')->title('Pages'))->save(); + Entry::make()->collection($collection)->slug('template-test')->data(['foo' => 'bar'])->template('some.template')->save(); + + $this->assertCount(0, EntryModel::all()); + + $this->artisan('statamic:eloquent:import-entries') + ->expectsOutputToContain('Entries imported successfully.') + ->assertExitCode(0); + + $this->assertCount(1, EntryModel::all()); + + $this->assertDatabaseHas('entries', ['collection' => 'pages', 'slug' => 'template-test', 'data' => '{"foo":"bar","template":"some.template"}']); + } } diff --git a/tests/Data/Entries/EntryQueryBuilderTest.php b/tests/Data/Entries/EntryQueryBuilderTest.php index 7f079af4..0faf0286 100644 --- a/tests/Data/Entries/EntryQueryBuilderTest.php +++ b/tests/Data/Entries/EntryQueryBuilderTest.php @@ -850,7 +850,7 @@ public function filtering_using_where_status_column_writes_deprecation_log() } #[Test] - public function filtering_using_whereIn_status_column_writes_deprecation_log() + public function filtering_using_where_in_status_column_writes_deprecation_log() { $this->withoutDeprecationHandling(); $this->expectException(\ErrorException::class);