diff --git a/src/Stache/Stores/CollectionTreeStore.php b/src/Stache/Stores/CollectionTreeStore.php index 5b0503fbfe..1caac172c0 100644 --- a/src/Stache/Stores/CollectionTreeStore.php +++ b/src/Stache/Stores/CollectionTreeStore.php @@ -5,7 +5,6 @@ use Statamic\Facades\Collection; use Statamic\Facades\Path; use Statamic\Structures\CollectionTree; -use Statamic\Support\Str; use Symfony\Component\Finder\SplFileInfo; class CollectionTreeStore extends NavTreeStore @@ -39,15 +38,4 @@ protected function newTreeClassByPath($path) ->locale($site) ->handle($handle); } - - public function getItemKey($item) - { - $key = parent::getItemKey($item); - - if (Str::startsWith($key, 'collection::')) { - $key = Str::after($key, 'collection::'); - } - - return $key; - } } diff --git a/tests/Feature/Collections/UpdateCollectionTreeTest.php b/tests/Feature/Collections/UpdateCollectionTreeTest.php index d23fe2b076..ab801e5ff4 100644 --- a/tests/Feature/Collections/UpdateCollectionTreeTest.php +++ b/tests/Feature/Collections/UpdateCollectionTreeTest.php @@ -15,12 +15,15 @@ class UpdateCollectionTreeTest extends TestCase use PreventSavingStacheItemsToDisk; use FakesRoles; - /** @test */ - public function it_updates_the_tree() + /** + * @test + * @dataProvider collectionTreeDataProvider + */ + public function it_updates_the_tree($collectionHandle) { $this->withoutExceptionHandling(); $user = tap(User::make()->makeSuper())->save(); - $collection = tap(Collection::make('test')->routes('{parent_uri}/{slug}'))->save(); + $collection = tap(Collection::make($collectionHandle)->routes('{parent_uri}/{slug}'))->save(); EntryFactory::id('e1')->collection($collection)->slug('a')->create(); EntryFactory::id('e2')->collection($collection)->slug('b')->create(); EntryFactory::id('e3')->collection($collection)->slug('c')->create(); @@ -59,6 +62,17 @@ public function it_updates_the_tree() ], $collection->structure()->in('en')->tree()); } + public function collectionTreeDataProvider() + { + return [ + 'arbitrary handle' => ['pages'], + 'handle of collection' => ['collection'], + 'handle ending with collection' => ['foo_collection'], + 'handle starting with collection' => ['collection_foo'], + 'handle with collection inside' => ['foo_collection_foo'], + ]; + } + /** @test */ public function it_doesnt_update_the_tree_if_theres_a_duplicate_uri_when_expecting_root() {