From f0860f8b520a56fbc0175498085a730992daf8d2 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Wed, 20 Nov 2024 18:36:52 +0000 Subject: [PATCH] [5.x] Add collection tests (#385) * Add collection test * Fix styling * Revert "Fix styling" This reverts commit 64910c7f3b5f900c6852b4af80c045c207daf023. --------- Co-authored-by: duncanmcclean --- tests/Collections/CollectionTest.php | 54 ++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 tests/Collections/CollectionTest.php diff --git a/tests/Collections/CollectionTest.php b/tests/Collections/CollectionTest.php new file mode 100644 index 00000000..02bd3ef3 --- /dev/null +++ b/tests/Collections/CollectionTest.php @@ -0,0 +1,54 @@ + 'Blog', + 'handle' => 'blog', + 'settings' => [ + 'routes' => '/blog/{slug}', + 'slugs' => true, + 'dated' => true, + 'template' => 'blog', + 'default_status' => false, + ], + ]); + + $find = CollectionFacade::find('blog'); + + $this->assertTrue($model->is($find->model())); + $this->assertEquals('blog', $find->handle()); + $this->assertEquals('Blog', $find->title()); + $this->assertEquals('/blog/{slug}', $find->route('en')); + $this->assertTrue($find->requiresSlugs()); + $this->assertTrue($find->dated()); + $this->assertEquals('blog', $find->template()); + $this->assertFalse($find->defaultPublishState()); + } + + #[Test] + public function it_saves_to_collection_model() + { + $collection = (new Collection)->handle('test'); + + $this->assertDatabaseMissing('collections', ['handle' => 'test']); + + $collection->save(); + + $this->assertDatabaseHas('collections', ['handle' => 'test']); + } +}