Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] Fix taxonomy routes on multi-site #10398

Merged
merged 6 commits into from
Jul 19, 2024
Merged
Changes from 1 commit
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
31 changes: 28 additions & 3 deletions tests/Data/Taxonomies/ViewsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,28 @@ class ViewsTest extends TestCase
private $frenchBlogEntry;
private $germanBlogEntry;
private $blogCollection;
private $tagsTaxonomy;

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

$this->setSites([
'en' => ['url' => '/', 'locale' => 'en'],
'de' => ['url' => '/de', 'locale' => 'de'],
'de' => ['url' => '/de/', 'locale' => 'de'],
'fr' => ['url' => '/fr/', 'locale' => 'fr'],
]);

$this->withStandardFakeViews();

Collection::make('pages')->routes('{slug}')->sites(['en', 'fr'])->save();
Collection::make('pages')->routes('{slug}')->sites(['en', 'de', 'fr'])->save();
$this->blogEntry = EntryFactory::collection('pages')->locale('en')->slug('the-blog')->create();
$this->frenchBlogEntry = EntryFactory::collection('pages')->locale('fr')->slug('le-blog')->origin($this->blogEntry->id())->create();
$this->germanBlogEntry = EntryFactory::collection('pages')->locale('de')->slug('der-blog')->origin($this->blogEntry->id())->create();

$this->blogCollection = tap(Collection::make('blog')->sites(['en', 'de', 'fr'])->taxonomies(['tags']))->save();

Taxonomy::make('tags')->sites(['en', 'fr'])->title('Tags')->save();
$this->tagsTaxonomy = tap(Taxonomy::make('tags')->sites(['en', 'fr'])->title('Tags'))->save();

tap(Term::make('test')->taxonomy('tags'), function ($term) {
$term->in('en')->slug('test')->set('title', 'Test');
Expand Down Expand Up @@ -106,6 +107,30 @@ public function the_collection_specific_taxonomy_url_404s_for_unconfigured_sites
$this->get('/de/der-blog/tags')->assertNotFound();
}

#[Test]
public function the_collection_specific_taxonomy_url_404s_when_collection_is_not_configured_for_that_site()
{
$this->mountBlogPageToBlogCollection();

// Set all the slugs to match the taxonomy, to make sure that the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I meant "Set all the slugs to match the taxonomy collection"

// missing localized collection URL isn't the thing causing the 404.
$this->blogEntry->in('en')->slug('blog')->save();
$this->blogEntry->in('fr')->slug('blog')->save();
$this->blogEntry->in('de')->slug('blog')->save();
$this->get('/blog')->assertOk();
$this->get('/fr/blog')->assertOk();
$this->get('/de/blog')->assertOk();

$this->tagsTaxonomy->sites(['en', 'fr', 'de'])->save();
$this->blogCollection->sites(['en', 'de'])->save();

$this->viewShouldReturnRaw('blog.tags.index', '{{ title }} index');

$this->get('/blog/tags')->assertOk()->assertSee('Tags index');
$this->get('/fr/blog/tags')->assertNotFound();
$this->get('/de/blog/tags')->assertOk()->assertSee('Tags index');
}

#[Test]
public function the_collection_specific_taxonomy_url_404s_if_the_view_doesnt_exist()
{
Expand Down