Skip to content

Commit

Permalink
Test that directory is never cleared when passing url args.
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseleite committed Jul 13, 2023
1 parent 9be567b commit 6674ccb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ public function generate($urls = '*')

Site::setCurrent(Site::default()->handle());

if ($urls) {
$this->disableClear = true; // TODO: Needs PR #136
if (is_array($urls)) {
$this->disableClear = true;
}

$this
Expand Down
22 changes: 16 additions & 6 deletions tests/GenerateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ public function it_generates_pages_for_site_fixture()
/** @test */
public function it_generates_specific_pages_when_passing_urls_as_args()
{
$this
->partialMock(Filesystem::class)
->shouldReceive('deleteDirectory')
->with(config('statamic.ssg.destination'), true)
->never();

$files = $this->generate(['urls' => ['/', 'topics', 'articles']]);

$expectedFiles = [
Expand Down Expand Up @@ -93,9 +99,8 @@ public function it_generates_pages_to_custom_destination()
/** @test */
public function it_clears_destination_directory_when_generating_site()
{
$files = $this->partialMock(Filesystem::class);

$files
$this
->partialMock(Filesystem::class)
->shouldReceive('deleteDirectory')
->with(config('statamic.ssg.destination'), true)
->once();
Expand All @@ -106,9 +111,8 @@ public function it_clears_destination_directory_when_generating_site()
/** @test */
public function it_can_generate_site_without_clearing_destination_directory()
{
$files = $this->partialMock(Filesystem::class);

$files
$this
->partialMock(Filesystem::class)
->shouldReceive('deleteDirectory')
->with(config('statamic.ssg.destination'), true)
->never();
Expand Down Expand Up @@ -296,6 +300,12 @@ public function it_generates_associated_paginated_pages_when_generating_only_url
EOT
);

$this
->partialMock(Filesystem::class)
->shouldReceive('deleteDirectory')
->with(config('statamic.ssg.destination'), true)
->never();

$files = $this->generate(['urls' => ['articles']]);

$expectedArticlesFiles = [
Expand Down
7 changes: 7 additions & 0 deletions tests/Localized/GenerateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Tests\Localized;

use Illuminate\Filesystem\Filesystem;
use Statamic\Facades\Config;
use Tests\Concerns\RunsGeneratorCommand;
use Tests\TestCase;
Expand Down Expand Up @@ -258,6 +259,12 @@ public function it_generates_associated_paginated_pages_when_generating_only_loc
EOT
);

$this
->partialMock(Filesystem::class)
->shouldReceive('deleteDirectory')
->with(config('statamic.ssg.destination'), true)
->never();

$files = $this->generate(['urls' => ['fr/le-articles']]);

$expectedArticlesFiles = [
Expand Down

0 comments on commit 6674ccb

Please sign in to comment.