Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
afonic committed Jun 8, 2024
1 parent fce00a4 commit 0074e17
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 45 deletions.
64 changes: 34 additions & 30 deletions tests/CreatesEntries.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ protected function makeEntry($site, $collection, $slug)

public function createMultisiteEntries()
{
$this->collection->structure()->makeTree('en')->save();
$this->collection->structure()->makeTree('fr')->save();
$this->collection->structure()->makeTree('gr')->save();
$this->collection->structure()->makeTree('de')->save();
$this->collection->structure()->makeTree('en', [])->save();
$this->collection->structure()->makeTree('fr', [])->save();
$this->collection->structure()->makeTree('gr', [])->save();
$this->collection->structure()->makeTree('de', [])->save();

$home = $this->makeEntry('en', $this->collection, 'home')->set('content', 'Home');
$homeFr = $home->makeLocalization('fr')->set('content', 'Accueil');
Expand All @@ -36,32 +36,36 @@ public function createMultisiteEntries()
$aboutFr->save();
$aboutGr->save();

$this->collection->structure()->in('en')->tree(
[
['entry' => 'home'],
['entry' => 'about'],
]
)->save();

$this->collection->structure()->in('fr')->tree(
[
['entry' => $homeFr->id()],
['entry' => $aboutFr->id()],
]
)->save();

$this->collection->structure()->in('gr')->tree(
[
['entry' => $homeGr->id()],
['entry' => $aboutGr->id()],
]
)->save();

$this->collection->structure()->in('de')->tree(
[
['entry' => $homeDe->id()],
]
)->save();
$structure = $this->collection->structure();

$treeEn = [
['entry' => $home->id()],
['entry' => $about->id()],
];

$treeFr = [
['entry' => $homeFr->id()],
['entry' => $aboutFr->id()],
];

$treeGr = [
['entry' => $homeGr->id()],
['entry' => $aboutGr->id()],
];

$treeDe = [
['entry' => $homeDe->id()],
];

$contentEn = $structure->validateTree($treeEn, 'en');
$contentFr = $structure->validateTree($treeFr, 'fr');
$contentGr = $structure->validateTree($treeGr, 'gr');
$contentDe = $structure->validateTree($treeDe, 'de');

$structure->in('en')->tree($contentEn)->save();
$structure->in('fr')->tree($contentFr)->save();
$structure->in('gr')->tree($contentGr)->save();
$structure->in('de')->tree($contentDe)->save();

}
}
2 changes: 1 addition & 1 deletion tests/Feature/LocaleBannerTagTest.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

use Illuminate\Support\Facades\Config;
use PHPUnit\Framework\Attributes\Test;
use Reach\LocaleLander\Tags\LocaleBanner;
use Reach\LocaleLander\Tests\CreatesEntries;
use Reach\LocaleLander\Tests\FakesViews;
use Reach\LocaleLander\Tests\PreventSavingStacheItemsToDisk;
use Reach\LocaleLander\Tests\TestCase;
use Statamic\Facades;
use Statamic\Facades\Antlers;
use PHPUnit\Framework\Attributes\Test;

class LocaleBannerTagTest extends TestCase
{
Expand Down
11 changes: 1 addition & 10 deletions tests/Feature/LocaleLanderTest.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<?php

use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Config;
use PHPUnit\Framework\Attributes\Test;
use Reach\LocaleLander\Tests\CreatesEntries;
use Reach\LocaleLander\Tests\FakesViews;
use Reach\LocaleLander\Tests\PreventSavingStacheItemsToDisk;
use Reach\LocaleLander\Tests\TestCase;
use Statamic\Facades;
use PHPUnit\Framework\Attributes\Test;

class LocaleLanderTest extends TestCase
{
Expand All @@ -27,16 +26,10 @@ public function setUp(): void
->routes('{parent_uri}/{slug}')
->structureContents([
'root' => true,
'max_depth' => 1,
])
->save();

$this->createMultisiteEntries();

Facades\Stache::clear();

Artisan::call('cache:clear');
Artisan::call('route:clear');
}

#[Test]
Expand All @@ -46,7 +39,6 @@ public function it_loads_homepage_for_each_language()
$this->get('/fr')->assertSee('Accueil');
$this->get('/gr')->assertSee('Αρχική');
$this->get('/de')->assertSee('Startseite');

}

#[Test]
Expand All @@ -55,7 +47,6 @@ public function it_loads_about_page_for_each_language()
$this->get('/about')->assertSee('About');
$this->get('/fr/a-props')->assertSee('propos');
$this->get('/gr/sxetika')->assertSee('Σχετικά');

}

#[Test]
Expand Down
10 changes: 6 additions & 4 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ protected function setUp(): void
Site::setSites([
'en' => [
'name' => 'English',
'url' => 'http://localhost/',
'url' => '/',
'locale' => 'en_US',
],
'fr' => [
'name' => 'French',
'url' => 'http://localhost/fr',
'url' => '/fr',
'locale' => 'fr_FR',
],
'de' => [
'name' => 'German',
'url' => 'http://localhost/de',
'url' => '/de',
'locale' => 'de_DE',
],
'gr' => [
'name' => 'Greek',
'url' => 'http://localhost/gr',
'url' => '/gr',
'locale' => 'el_GR',
],
]);
Expand Down Expand Up @@ -112,8 +112,10 @@ protected function getEnvironmentSetUp($app)
$app['config']->set('statamic.stache.stores.asset-containers.directory', __DIR__.'/__fixtures__/content/assets');
$app['config']->set('statamic.stache.stores.nav-trees.directory', __DIR__.'/__fixtures__/content/structures/navigation');
$app['config']->set('statamic.stache.stores.collection-trees.directory', __DIR__.'/__fixtures__/content/structures/collections');
$app['config']->set('statamic.stache.stores.form-submissions.directory', __DIR__.'/__fixtures__/content/submissions');

$app['config']->set('statamic.editions.pro', true);
$app['config']->set('statamic.system.multisite', true);

$app['config']->set('cache.stores.outpost', [
'driver' => 'file',
Expand Down

0 comments on commit 0074e17

Please sign in to comment.