From 34509e01a4c474f0096ca4bc1d3d252502e10d70 Mon Sep 17 00:00:00 2001 From: Guillermo Cava Date: Fri, 19 Sep 2025 18:53:50 -0500 Subject: [PATCH 1/6] working upgrade deps --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index d2d3211..8a0d97f 100644 --- a/composer.json +++ b/composer.json @@ -12,11 +12,11 @@ "laravel" ], "require": { - "tightenco/jigsaw": "^1.3.27", - "torchlight/torchlight-laravel": "^0.5.10" + "tightenco/jigsaw": "^1.8", + "torchlight/torchlight-laravel": "^0.6" }, "require-dev": { - "phpunit/phpunit": "^8.4" + "phpunit/phpunit": "^11.0" }, "autoload": { "psr-4": { From f61e3edffd113fbe08087bac165b57a3ca3d1000 Mon Sep 17 00:00:00 2001 From: Guillermo Cava Date: Wed, 1 Oct 2025 09:19:19 -0500 Subject: [PATCH 2/6] test suite in passing state --- .gitignore | 1 + phpunit.xml.dist | 23 ++--------- tests/BaseTest.php | 100 ++++++++++++++++++++++++++++++++------------- 3 files changed, 77 insertions(+), 47 deletions(-) diff --git a/.gitignore b/.gitignore index 4913b8e..35f74f1 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ composer.lock .phpunit.result.cache tests/Site/build_testing/ tests/Site/torchlight.php +.phpunit.cache/ diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d434150..24da3b8 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,24 +1,9 @@ - + - tests + tests + vendor - - - src/ - - - - - \ No newline at end of file + diff --git a/tests/BaseTest.php b/tests/BaseTest.php index cb77210..fde375e 100644 --- a/tests/BaseTest.php +++ b/tests/BaseTest.php @@ -11,9 +11,13 @@ use Illuminate\Http\Client\Factory; use Illuminate\Http\Client\Request; use Illuminate\Support\Facades\Http; +use Illuminate\View\Component; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; +use TightenCo\Jigsaw\Bootstrap\HandleExceptions; use TightenCo\Jigsaw\Console\BuildCommand; +use TightenCo\Jigsaw\File\Filesystem; use TightenCo\Jigsaw\Jigsaw; use Torchlight\Block; use Torchlight\Jigsaw\Exceptions\UnrenderedBlockException; @@ -26,48 +30,80 @@ class BaseTest extends TestCase protected $container; - protected function prepareForBuilding() + protected Filesystem $filesystem; + + protected string $sitePath; + + public function __construct($name = null, array $data = [], $dataName = '') { - $sitePath = __DIR__ . '/Site'; + parent::__construct($name, $data, $dataName); + + $this->sitePath = __DIR__ . '/Site'; + + $this->filesystem = new Filesystem; + } - // Clear out the old build directory. - if (is_dir("$sitePath/build_testing")) { - exec("rm -rf $sitePath/build_testing"); + protected function tearDown(): void + { + if ($this->container) { + $this->container->flush(); } - // Clear the old config. - if (file_exists("$sitePath/torchlight.php")) { - exec("rm $sitePath/torchlight.php"); + if (method_exists(Component::class, 'flushCache')) { + Component::flushCache(); + Component::forgetComponentsResolver(); + Component::forgetFactory(); } - /** - * These next lines basically mimic the /vendor/bin/jigsaw.php file. - */ - require realpath(__DIR__ . '/../vendor/tightenco/jigsaw/jigsaw-core.php'); + if ($this->status()->isSuccess()) { + $this->filesystem->deleteDirectory(app()->cachePath()); + + $this->filesystem->delete("$this->sitePath/torchlight.php"); + } + + HandleExceptions::flushState(); + + parent::tearDown(); + } - $this->app = new Application('Jigsaw', '1.3.37'); + protected function prepareForBuilding() + { + $this->app = new \Symfony\Component\Console\Application('Jigsaw', '1.8.2'); /** @var Container $container */ - $this->container = $container; + $this->container = new \TightenCo\Jigsaw\Container; + + // Bootstrap error handling like official Jigsaw + $this->container->singleton( + \Illuminate\Contracts\Debug\ExceptionHandler::class, + \TightenCo\Jigsaw\Exceptions\Handler::class, + ); + + $this->container->bootstrapWith([ + \TightenCo\Jigsaw\Bootstrap\HandleExceptions::class, + ]); - $this->container->instance('cwd', $sitePath); + // Set up paths correctly $this->container->buildPath = [ - 'source' => $sitePath, - 'views' => $sitePath, - 'destination' => "$sitePath/build_testing", + 'source' => $this->sitePath, + 'views' => $this->sitePath, + 'destination' => "$this->sitePath/build_testing", ]; + // Set environment + $this->container['env'] = 'testing'; + // There are other Jigsaw commands we could register, // but we dont' need them so we don't add them. $this->app->add(new BuildCommand($this->container)); - Jigsaw::addUserCommands($this->app, $this->container); // This is from the bottom of jigsaw-core.php. We have to do it // ourselves since we're in a different working directory than // that file expects us to be. + $container = $this->container; $events = $this->container->events; - include "$sitePath/bootstrap.php"; + include "$this->sitePath/bootstrap.php"; Http::swap(new Factory); } @@ -76,8 +112,16 @@ protected function build($source = 'source-1') { // Turn off the Jigsaw progress bars. $this->container->consoleOutput->setup($verbosity = -1); + + // Update build paths for the specific source + // Keep views pointing to main Site directory where _layouts are located + $this->container->buildPath = [ + 'source' => __DIR__ . "/Site/$source", + 'views' => __DIR__ . "/Site", + 'destination' => __DIR__ . "/Site/build_testing", + ]; + $jigsaw = $this->container->make(Jigsaw::class); - $jigsaw->setSourcePath(__DIR__ . "/Site/$source"); $jigsaw->build('testing'); } @@ -89,7 +133,7 @@ protected function assertSnapshotMatches($file) $this->assertEquals($expected, $actual, "Checking snapshot $file"); } - /** @test */ + #[Test] public function most_of_the_tests_are_here() { TorchlightExtension::macro('afterStandaloneConfiguration', function () { @@ -126,7 +170,7 @@ public function most_of_the_tests_are_here() $this->assertSnapshotMatches('code-indents-work'); } - /** @test */ + #[Test] public function no_blocks_doesnt_create_an_error() { TorchlightExtension::macro('afterStandaloneConfiguration', function () { @@ -145,7 +189,7 @@ public function no_blocks_doesnt_create_an_error() $this->assertTrue(true); } - /** @test */ + #[Test] public function non_existent_block_throws() { TorchlightExtension::macro('afterStandaloneConfiguration', function () { @@ -167,7 +211,7 @@ public function non_existent_block_throws() $this->assertTrue(false); } - /** @test */ + #[Test] public function expected_non_existent_block_is_fine() { TorchlightExtension::macro('afterStandaloneConfiguration', function () { @@ -187,7 +231,7 @@ public function expected_non_existent_block_is_fine() $this->assertTrue(true); } - /** @test */ + #[Test] public function can_manually_add_blocks() { TorchlightExtension::macro('afterStandaloneConfiguration', function () { @@ -242,7 +286,7 @@ public function can_manually_add_blocks() $this->assertSnapshotMatches('manually-added'); } - /** @test */ + #[Test] public function dark_mode_works() { TorchlightExtension::macro('afterStandaloneConfiguration', function () { @@ -317,7 +361,7 @@ public function dark_mode_works() $this->assertSnapshotMatches('dark-mode'); } - /** @test */ + #[Test] public function test_publish_command() { $this->assertFalse(file_exists(__DIR__ . '/Site/torchlight.php')); From 1738694abb6551e258601120a3d2b741e02fddc9 Mon Sep 17 00:00:00 2001 From: Guillermo Cava Date: Wed, 1 Oct 2025 09:27:34 -0500 Subject: [PATCH 3/6] tweaks --- tests/BaseTest.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/BaseTest.php b/tests/BaseTest.php index fde375e..bbb0c23 100644 --- a/tests/BaseTest.php +++ b/tests/BaseTest.php @@ -7,7 +7,7 @@ use Illuminate\Cache\NullStore; use Illuminate\Cache\Repository; -use Illuminate\Container\Container; +use TightenCo\Jigsaw\Container; use Illuminate\Http\Client\Factory; use Illuminate\Http\Client\Request; use Illuminate\Support\Facades\Http; @@ -68,12 +68,13 @@ protected function tearDown(): void protected function prepareForBuilding() { + // Keeping it fully qualified here to make it easier + // to compare with the jigsaw initialization flow $this->app = new \Symfony\Component\Console\Application('Jigsaw', '1.8.2'); /** @var Container $container */ $this->container = new \TightenCo\Jigsaw\Container; - // Bootstrap error handling like official Jigsaw $this->container->singleton( \Illuminate\Contracts\Debug\ExceptionHandler::class, \TightenCo\Jigsaw\Exceptions\Handler::class, @@ -83,21 +84,19 @@ protected function prepareForBuilding() \TightenCo\Jigsaw\Bootstrap\HandleExceptions::class, ]); - // Set up paths correctly $this->container->buildPath = [ 'source' => $this->sitePath, 'views' => $this->sitePath, 'destination' => "$this->sitePath/build_testing", ]; - // Set environment $this->container['env'] = 'testing'; // There are other Jigsaw commands we could register, // but we dont' need them so we don't add them. $this->app->add(new BuildCommand($this->container)); - // This is from the bottom of jigsaw-core.php. We have to do it + // This is from the bottom of jigsaw. We have to do it // ourselves since we're in a different working directory than // that file expects us to be. $container = $this->container; @@ -113,8 +112,6 @@ protected function build($source = 'source-1') // Turn off the Jigsaw progress bars. $this->container->consoleOutput->setup($verbosity = -1); - // Update build paths for the specific source - // Keep views pointing to main Site directory where _layouts are located $this->container->buildPath = [ 'source' => __DIR__ . "/Site/$source", 'views' => __DIR__ . "/Site", From fa447c5902e26d62c1b6fad86336297722baa1be Mon Sep 17 00:00:00 2001 From: Guillermo Cava Date: Wed, 1 Oct 2025 09:42:09 -0500 Subject: [PATCH 4/6] styles --- tests/BaseTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/BaseTest.php b/tests/BaseTest.php index bbb0c23..930fa1c 100644 --- a/tests/BaseTest.php +++ b/tests/BaseTest.php @@ -68,7 +68,7 @@ protected function tearDown(): void protected function prepareForBuilding() { - // Keeping it fully qualified here to make it easier + // Keeping it fully qualified here to make it easier // to compare with the jigsaw initialization flow $this->app = new \Symfony\Component\Console\Application('Jigsaw', '1.8.2'); @@ -114,7 +114,7 @@ protected function build($source = 'source-1') $this->container->buildPath = [ 'source' => __DIR__ . "/Site/$source", - 'views' => __DIR__ . "/Site", + 'views' => __DIR__ . "/Site", 'destination' => __DIR__ . "/Site/build_testing", ]; From cbebf24e3e4743f6f71fcfb53e209a619e835b73 Mon Sep 17 00:00:00 2001 From: Guillermo Cava Date: Wed, 1 Oct 2025 09:43:23 -0500 Subject: [PATCH 5/6] styles --- tests/BaseTest.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/BaseTest.php b/tests/BaseTest.php index 930fa1c..2f807b5 100644 --- a/tests/BaseTest.php +++ b/tests/BaseTest.php @@ -7,16 +7,15 @@ use Illuminate\Cache\NullStore; use Illuminate\Cache\Repository; -use TightenCo\Jigsaw\Container; use Illuminate\Http\Client\Factory; use Illuminate\Http\Client\Request; use Illuminate\Support\Facades\Http; use Illuminate\View\Component; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; -use Symfony\Component\Console\Application; use TightenCo\Jigsaw\Bootstrap\HandleExceptions; use TightenCo\Jigsaw\Console\BuildCommand; +use TightenCo\Jigsaw\Container; use TightenCo\Jigsaw\File\Filesystem; use TightenCo\Jigsaw\Jigsaw; use Torchlight\Block; @@ -114,8 +113,8 @@ protected function build($source = 'source-1') $this->container->buildPath = [ 'source' => __DIR__ . "/Site/$source", - 'views' => __DIR__ . "/Site", - 'destination' => __DIR__ . "/Site/build_testing", + 'views' => __DIR__ . '/Site', + 'destination' => __DIR__ . '/Site/build_testing', ]; $jigsaw = $this->container->make(Jigsaw::class); From a9fc4fe49d661daed46c124761689412524fe337 Mon Sep 17 00:00:00 2001 From: Guillermo Cava Date: Wed, 1 Oct 2025 09:43:46 -0500 Subject: [PATCH 6/6] styles --- tests/BaseTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/BaseTest.php b/tests/BaseTest.php index 2f807b5..ed2d4eb 100644 --- a/tests/BaseTest.php +++ b/tests/BaseTest.php @@ -1,4 +1,5 @@ */