-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add collection test * Fix styling * Revert "Fix styling" This reverts commit 64910c7. --------- Co-authored-by: duncanmcclean <[email protected]>
- Loading branch information
1 parent
3503966
commit f0860f8
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace Collections; | ||
|
||
use Illuminate\Foundation\Testing\RefreshDatabase; | ||
use PHPUnit\Framework\Attributes\Test; | ||
use Statamic\Eloquent\Collections\Collection; | ||
use Statamic\Eloquent\Collections\CollectionModel; | ||
use Statamic\Facades\Collection as CollectionFacade; | ||
use Tests\TestCase; | ||
|
||
class CollectionTest extends TestCase | ||
{ | ||
use RefreshDatabase; | ||
|
||
#[Test] | ||
public function it_finds_collection() | ||
{ | ||
$model = CollectionModel::create([ | ||
'title' => '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']); | ||
} | ||
} |