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 src/Stache/Stores/CollectionEntriesStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,13 @@ protected function storeIndexes()
{
$indexes = collect([
'slug',
'uri',
'collectionHandle',
'published',
'title',
'site' => Indexes\Site::class,
'origin' => Indexes\Origin::class,
'parent' => Indexes\Parents::class,
'uri',
]);

if (! $collection = Collection::findByHandle($this->childKey())) {
Expand Down
50 changes: 50 additions & 0 deletions tests/Stache/OrderableEntryUriTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace Tests\Stache;

use PHPUnit\Framework\Attributes\Test;
use Statamic\Facades\Blink;
use Statamic\Facades\Collection;
use Statamic\Facades\Entry;
use Statamic\Facades\Stache;
use Tests\PreventSavingStacheItemsToDisk;
use Tests\TestCase;

class OrderableEntryUriTest extends TestCase
{
use PreventSavingStacheItemsToDisk;

public function setUp(): void
{
parent::setUp();

$collection = Collection::make('vehicles')
->routes('/vehicles/{slug}')
->structureContents(['max_depth' => 1]);
$collection->save();
}

private function simulateNewRequest(): void
{
Blink::flush();
Stache::stores()->each->resetMemoizedState();
app('stache.indexes')->each->resetMemoizedState();
}

#[Test]
public function entries_have_uris_and_orders_after_being_saved()
{
Entry::make()->collection('vehicles')->slug('car')->data(['title' => 'Car'])->save();

$this->simulateNewRequest();

Entry::make()->collection('vehicles')->slug('bus')->data(['title' => 'Bus'])->save();

$this->simulateNewRequest();

$this->assertNotNull($car = Entry::findByUri('/vehicles/car'));
$this->assertNotNull($bus = Entry::findByUri('/vehicles/bus'));
$this->assertEquals(1, $car->order());
$this->assertEquals(2, $bus->order());
}
}
Loading