Skip to content
This repository has been archived by the owner on Oct 6, 2022. It is now read-only.

Commit

Permalink
related #68
Browse files Browse the repository at this point in the history
  • Loading branch information
bnomei committed Oct 16, 2021
1 parent 4909dc8 commit c347423
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
23 changes: 19 additions & 4 deletions tests/AutoidTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ public function randomPage(): ?Page
return site()->pages()->index()->notTemplate('home')->shuffle()->first();
}

public function randomPageWithChildren(): ?Page
{
$randomPage = null;
$hasChildren = false;
while (!$hasChildren) {
$randomPage = $this->randomPage();
$hasChildren = $randomPage->hasChildren();
}

return $randomPage;
}

public function randomFile(): ?File
{
return site()->pages()->index()->notTemplate('home')->files()->shuffle()->first();
Expand Down Expand Up @@ -378,21 +390,24 @@ public function testChangeSlugWillRedindexChildren()

public function testFindByTemplate()
{
// AutoID::flush();
// AutoID::index(true);
//AutoID::flush();
//AutoID::index(true);

$randomPage = $this->randomPage();
$randomPage = $this->randomPageWithChildren();
$collection = AutoIDDatabase::singleton()->findByTemplate(
'autoidtest',
$randomPage->id()
);
$this->assertTrue($collection->count() > 0);
$this->assertEquals($randomPage->index()->not($randomPage)->count(), $collection->count());

$randomPage = $this->randomPage();
$randomPage = $this->randomPageWithChildren();
$collection = $randomPage->searchForTemplate('autoidtest');
$this->assertTrue($collection->count() > 0);
$this->assertEquals($randomPage->index()->not($randomPage)->count(), $collection->count());

$collection = site()->searchForTemplate('autoidtest');
$this->assertTrue($collection->count() > 0);
$this->assertEquals(site()->index()->notTemplate('home')->count(), $collection->count());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Autoid: ghovfvy7
Autoid: 92p7cnw5

----

Expand Down

0 comments on commit c347423

Please sign in to comment.