Skip to content

Commit de9b33c

Browse files
committed
add test to cover updating entries
1 parent e0e99b2 commit de9b33c

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

tests/Feature/Entries/UpdateEntryTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,41 @@ public function does_not_validate_max_depth_when_collection_max_depth_is_null()
469469
->assertOk();
470470
}
471471

472+
#[Test]
473+
public function it_prevents_duplicate_uris_for_structured_entries_with_depth_conditional_routes()
474+
{
475+
$this->setTestRoles(['test' => ['access cp', 'edit test entries', 'access en site']]);
476+
$user = tap(User::make()->assignRole('test'))->save();
477+
478+
$collection = tap(
479+
Collection::make('test')
480+
->routes('{{ if depth > 1 }}{{ parent_uri }}/{{ slug }}{{ else }}base/{{ slug }}{{ /if }}')
481+
->structureContents(['max_depth' => 10])
482+
)->save();
483+
484+
EntryFactory::id('root-id')->slug('root')->collection('test')->create();
485+
EntryFactory::id('child-id')->slug('child')->collection('test')->create();
486+
487+
$entry = EntryFactory::id('other-child-id')
488+
->slug('other-child')
489+
->collection('test')
490+
->data(['title' => 'Other Child'])
491+
->create();
492+
493+
$collection->structure()->in('en')->tree([
494+
['entry' => 'root-id', 'children' => [
495+
['entry' => 'child-id'],
496+
['entry' => 'other-child-id'],
497+
]],
498+
])->save();
499+
500+
$this
501+
->actingAs($user)
502+
->update($entry, ['title' => 'Other Child', 'slug' => 'child'])
503+
->assertStatus(422)
504+
->assertJsonValidationErrors(['slug']);
505+
}
506+
472507
private function seedUserAndCollection()
473508
{
474509
$this->setTestRoles(['test' => [

0 commit comments

Comments
 (0)