diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index febb013..0f2ad1e 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -13,7 +13,7 @@ on: jobs: cs: name: 'Check coding style' - runs-on: latest + runs-on: ubuntu-latest steps: - name: 'Checkout current revision' @@ -48,7 +48,7 @@ jobs: unit: name: 'Run unit tests' - runs-on: latest + runs-on: ubuntu-latest strategy: fail-fast: false diff --git a/README.md b/README.md index f9e9296..f287c40 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,11 @@ A Vite plugin and CakePHP helper that connect a Vite build to a CakePHP applicat ## Requirements -| Dependency | Version | -|------------|---------| -| PHP | ≥ 8.3 | -| CakePHP | ^4.5 | -| Vite | ^6.0 | +| Dependency | Version | +|------------|-----------------| +| PHP | ≥ 8.3 | +| CakePHP | ^4.5 || ^5.0 | +| Vite | ^6.0 | ## Installation diff --git a/composer.json b/composer.json index 13c6764..4271ee1 100644 --- a/composer.json +++ b/composer.json @@ -14,11 +14,11 @@ "require": { "php": ">=8.3", "ext-json": "*", - "cakephp/cakephp": "^4.5" + "cakephp/cakephp": "^4.5 || ^5.0" }, "require-dev": { - "phpunit/phpunit": "^8.5 || ^9.3", - "cakephp/cakephp-codesniffer": "~4.2.0" + "phpunit/phpunit": "^10.5.5 || ^11.1.3 || ^12.1", + "cakephp/cakephp-codesniffer": "^4.7" }, "autoload": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4fd546f..c3bc4dc 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -7,7 +7,6 @@ > - @@ -19,12 +18,12 @@ - + - - + + src/ - - + + diff --git a/src/View/Helper/RnaHelper.php b/src/View/Helper/RnaHelper.php index 8ccb375..d0ec08e 100644 --- a/src/View/Helper/RnaHelper.php +++ b/src/View/Helper/RnaHelper.php @@ -4,6 +4,7 @@ namespace Chialab\Vite\View\Helper; use Cake\View\Helper; +use function Cake\Core\pluginSplit; /** * Rna compatible helper @@ -16,12 +17,12 @@ class RnaHelper extends Helper /** * @inheritDoc */ - public $helpers = ['Html', 'Vite']; + public array $helpers = ['Html', 'Vite']; /** * @inheritDoc */ - protected $_defaultConfig = [ + protected array $_defaultConfig = [ 'buildPath' => WWW_ROOT . 'build', 'entrypointFile' => 'entrypoints.json', ]; diff --git a/src/View/Helper/ViteHelper.php b/src/View/Helper/ViteHelper.php index b7301ad..69141ef 100644 --- a/src/View/Helper/ViteHelper.php +++ b/src/View/Helper/ViteHelper.php @@ -29,12 +29,12 @@ class ViteHelper extends Helper /** * @var array */ - protected $helpers = ['Html']; + protected array $helpers = ['Html']; /** * @var array */ - protected $_defaultConfig = [ + protected array $_defaultConfig = [ // Filesystem path to the build directory. Defaults to WWW_ROOT . 'dist'. 'buildPath' => null, // Public base prepended to the manifest paths. A leading "/" makes diff --git a/tests/TestCase/View/Helper/ViteHelperTest.php b/tests/TestCase/View/Helper/ViteHelperTest.php index 5ec2e0d..72b916a 100644 --- a/tests/TestCase/View/Helper/ViteHelperTest.php +++ b/tests/TestCase/View/Helper/ViteHelperTest.php @@ -3,6 +3,7 @@ namespace Chialab\Vite\Test\TestCase\View\Helper; +use Cake\Core\Configure; use Cake\TestSuite\TestCase; use Cake\View\View; use Chialab\Vite\View\Helper\ViteHelper; @@ -42,4 +43,18 @@ protected function tearDown(): void parent::tearDown(); } + + /** + * Test that no tags are emitted when the manifest is missing. + * + * @return void + */ + public function testMissingManifest(): void + { + Configure::write('debug', false); + $this->Vite->setConfig(['buildPath' => TMP . 'missing-build'], null, false); + + static::assertSame('', $this->Vite->css('app')); + static::assertSame('', $this->Vite->js('app')); + } } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 5a5d122..7e3acd6 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -38,18 +38,3 @@ return; } - -/** - * Load schema from a SQL dump file. - * - * If your plugin does not use database fixtures you can - * safely delete this. - * - * If you want to support multiple databases, consider - * using migrations to provide schema for your plugin, - * and using \Migrations\TestSuite\Migrator to load schema. - */ -use Cake\TestSuite\Fixture\SchemaLoader; - -// Load a schema dump file. -(new SchemaLoader())->loadSqlFiles('tests/schema.sql', 'test');