Skip to content
Merged
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
3 changes: 2 additions & 1 deletion tests/ConcurrentTasksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

namespace Tests;

use PHPUnit\Framework\Attributes\Test;
use Spatie\Fork\Fork;
use Statamic\StaticSite\ConcurrentTasks;

class ConcurrentTasksTest extends TestCase
{
/** @test */
#[Test]
public function it_runs_callbacks()
{
$one = function () {
Expand Down
3 changes: 2 additions & 1 deletion tests/ConsecutiveTasksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace Tests;

use PHPUnit\Framework\Attributes\Test;
use Statamic\StaticSite\ConsecutiveTasks;

class ConsecutiveTasksTest extends TestCase
{
/** @test */
#[Test]
public function it_runs_callbacks()
{
$callbacksRan = 0;
Expand Down
23 changes: 12 additions & 11 deletions tests/GenerateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Tests;

use Illuminate\Filesystem\Filesystem;
use PHPUnit\Framework\Attributes\Test;
use Statamic\Facades\Config;
use Statamic\Facades\URL;
use Tests\Concerns\RunsGeneratorCommand;
Expand All @@ -19,7 +20,7 @@ protected function tearDown(): void
parent::tearDown();
}

/** @test */
#[Test]
public function it_generates_pages_for_site_fixture()
{
$files = $this->generate();
Expand Down Expand Up @@ -68,7 +69,7 @@ public function it_generates_pages_for_site_fixture()
$this->assertStringContainsString('<h1>Article Title: Eight</h1>', $files['articles/eight/index.html']);
}

/** @test */
#[Test]
public function it_generates_specific_pages_when_passing_urls_as_args()
{
$this
Expand All @@ -92,7 +93,7 @@ public function it_generates_specific_pages_when_passing_urls_as_args()
$this->assertStringContainsString('<h1>Articles Index Page Title</h1>', $files['articles/index.html']);
}

/** @test */
#[Test]
public function it_generates_pages_to_custom_destination()
{
Config::set('statamic.ssg.destination', $this->destination = base_path('custom_export'));
Expand All @@ -105,7 +106,7 @@ public function it_generates_pages_to_custom_destination()
$this->cleanUpDestination();
}

/** @test */
#[Test]
public function it_clears_destination_directory_when_generating_site()
{
$this
Expand All @@ -117,7 +118,7 @@ public function it_clears_destination_directory_when_generating_site()
$this->generate();
}

/** @test */
#[Test]
public function it_can_generate_site_without_clearing_destination_directory()
{
$this
Expand All @@ -129,7 +130,7 @@ public function it_can_generate_site_without_clearing_destination_directory()
$this->generate(['--disable-clear' => true]);
}

/** @test */
#[Test]
public function it_generates_paginated_pages()
{
$this->files->put(resource_path('views/articles/index.antlers.html'), <<<'EOT'
Expand Down Expand Up @@ -207,7 +208,7 @@ public function it_generates_paginated_pages()
$this->assertStringContainsString('Prev Link: /articles/page/2', $index);
}

/** @test */
#[Test]
public function it_generates_pagination_with_custom_page_name_and_route()
{
// Here we'll override the `pagination_route`.
Expand Down Expand Up @@ -290,7 +291,7 @@ public function it_generates_pagination_with_custom_page_name_and_route()
$this->assertStringContainsString('Prev Link: /articles/p-2', $index);
}

/** @test */
#[Test]
public function it_generates_associated_paginated_pages_when_generating_only_urls_with_pagination()
{
$this->files->put(resource_path('views/articles/index.antlers.html'), <<<'EOT'
Expand Down Expand Up @@ -364,7 +365,7 @@ public function it_generates_associated_paginated_pages_when_generating_only_url
$this->assertStringContainsString('Prev Link: /articles/page/2', $index);
}

/** @test */
#[Test]
public function it_enforces_trailing_slashes_when_config_enabled()
{
Config::set('statamic.ssg.enforce_trailing_slashes', true);
Expand All @@ -377,7 +378,7 @@ public function it_enforces_trailing_slashes_when_config_enabled()
$this->assertStringContainsString('<a href="http://cool-runnings.com/articles/three/">Three</a>', $index);
}

/** @test */
#[Test]
public function it_enforces_trailing_slashes_on_paginated_urls_when_config_enabled()
{
Config::set('statamic.ssg.enforce_trailing_slashes', true);
Expand Down Expand Up @@ -411,7 +412,7 @@ public function it_enforces_trailing_slashes_on_paginated_urls_when_config_enabl
$this->assertStringContainsString('Prev Link: /articles/page/2/', $page3);
}

/** @test */
#[Test]
public function it_still_generates_404_when_trailing_slashes_config_is_enabled()
{
Config::set('statamic.ssg.enforce_trailing_slashes', true);
Expand Down
15 changes: 8 additions & 7 deletions tests/Localized/GenerateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Tests\Localized;

use Illuminate\Filesystem\Filesystem;
use PHPUnit\Framework\Attributes\Test;
use Statamic\Facades\Config;
use Statamic\Facades\Site;
use Statamic\Facades\URL;
Expand Down Expand Up @@ -49,7 +50,7 @@ protected function tearDown(): void
parent::tearDown();
}

/** @test */
#[Test]
public function it_generates_pages_for_localized_site_fixture()
{
$files = $this->generate();
Expand Down Expand Up @@ -124,7 +125,7 @@ public function it_generates_pages_for_localized_site_fixture()
$this->assertStringContainsString('<h1>Article Title: Le Five</h1>', $files['fr/le-articles/le-five/index.html']);
}

/** @test */
#[Test]
public function it_generates_localized_paginated_pages()
{
$this->files->put(resource_path('views/articles/index.antlers.html'), <<<'EOT'
Expand Down Expand Up @@ -185,7 +186,7 @@ public function it_generates_localized_paginated_pages()
$this->assertStringContainsString('Prev Link: /fr/le-articles/page/1', $index);
}

/** @test */
#[Test]
public function it_generates_localized_pagination_with_custom_page_name_and_route()
{
// Here we'll override the `pagination_route`.
Expand Down Expand Up @@ -251,7 +252,7 @@ public function it_generates_localized_pagination_with_custom_page_name_and_rout
$this->assertStringContainsString('Prev Link: /fr/le-articles/p-1', $index);
}

/** @test */
#[Test]
public function it_generates_associated_paginated_pages_when_generating_only_localized_urls_with_pagination()
{
$this->files->put(resource_path('views/articles/index.antlers.html'), <<<'EOT'
Expand Down Expand Up @@ -311,7 +312,7 @@ public function it_generates_associated_paginated_pages_when_generating_only_loc
$this->assertStringContainsString('Prev Link: /fr/le-articles/page/1', $index);
}

/** @test */
#[Test]
public function it_enforces_trailing_slashes_when_config_enabled()
{
Config::set('statamic.ssg.enforce_trailing_slashes', true);
Expand All @@ -329,7 +330,7 @@ public function it_enforces_trailing_slashes_when_config_enabled()
$this->assertStringContainsString('<a href="http://cool-runnings.com/fr/le-articles/le-three/">Le Three</a>', $frIndex);
}

/** @test */
#[Test]
public function it_enforces_trailing_slashes_on_localized_paginated_urls_when_config_enabled()
{
Config::set('statamic.ssg.enforce_trailing_slashes', true);
Expand Down Expand Up @@ -362,7 +363,7 @@ public function it_enforces_trailing_slashes_on_localized_paginated_urls_when_co
$this->assertStringContainsString('Prev Link: /fr/le-articles/page/1/', $frPage2);
}

/** @test */
#[Test]
public function it_still_generates_404_when_trailing_slashes_config_is_enabled()
{
Config::set('statamic.ssg.enforce_trailing_slashes', true);
Expand Down
7 changes: 4 additions & 3 deletions tests/PageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
namespace Tests;

use Illuminate\Filesystem\Filesystem;
use PHPUnit\Framework\Attributes\Test;
use Statamic\Contracts\Entries\Entry;
use Statamic\StaticSite\Page;

class PageTest extends TestCase
{
/** @test */
#[Test]
public function it_gets_the_path()
{
$entry = $this->mock(Entry::class);
Expand All @@ -20,7 +21,7 @@ public function it_gets_the_path()
$this->assertEquals('/path/to/static/foo/bar', $page->directory());
}

/** @test */
#[Test]
public function it_gets_the_path_of_a_url_with_a_file_extension()
{
$entry = $this->mock(Entry::class);
Expand All @@ -32,7 +33,7 @@ public function it_gets_the_path_of_a_url_with_a_file_extension()
$this->assertEquals('/path/to/static/foo/bar', $page->directory());
}

/** @test */
#[Test]
public function it_gets_the_path_of_the_404_url()
{
$entry = $this->mock(Entry::class);
Expand Down
11 changes: 6 additions & 5 deletions tests/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Tests;

use PHPUnit\Framework\Attributes\Test;
use Statamic\Entries\Collection;
use Statamic\Entries\Entry;
use Statamic\Facades\Site;
Expand All @@ -10,14 +11,14 @@

class RequestTest extends TestCase
{
/** @test */
#[Test]
public function gets_scheme()
{
$this->assertEquals('http', (new Request)->setConfig(['base_url' => 'http://test.com'])->getScheme());
$this->assertEquals('https', (new Request)->setConfig(['base_url' => 'https://test.com'])->getScheme());
}

/** @test */
#[Test]
public function gets_http_host()
{
$this->assertEquals('test.com', (new Request)->setConfig(['base_url' => 'http://test.com'])->getHttpHost());
Expand All @@ -26,7 +27,7 @@ public function gets_http_host()
$this->assertEquals('test.com', (new Request)->setConfig(['base_url' => 'https://test.com/subdirectory/'])->getHttpHost());
}

/** @test */
#[Test]
public function gets_base_url()
{
$this->assertEquals('', (new Request)->setConfig(['base_url' => 'http://test.com'])->getBaseUrl());
Expand All @@ -35,7 +36,7 @@ public function gets_base_url()
$this->assertEquals('/subdirectory', (new Request)->setConfig(['base_url' => 'http://test.com/subdirectory/'])->getBaseUrl());
}

/** @test */
#[Test]
public function gets_path()
{
// The current site needs to be explicitly set, otherwise it will try to
Expand All @@ -55,7 +56,7 @@ public function gets_path()
$this->assertEquals('foo', $request->path());
}

/** @test */
#[Test]
public function it_can_forget_query_param()
{
$request = new Request;
Expand Down