diff --git a/README.md b/README.md index 840f173..5078a91 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Tatter\Frontend -Bundled integration of preferred frontend tech, for CodeIgniter 4 +Opinionated suite of frontend tech for CodeIgniter 4 [![](https://github.com/tattersoftware/codeigniter4-frontend/workflows/PHPUnit/badge.svg)](https://github.com/tattersoftware/codeigniter4-frontend/actions/workflows/test.yml) [![](https://github.com/tattersoftware/codeigniter4-frontend/workflows/PHPStan/badge.svg)](https://github.com/tattersoftware/codeigniter4-frontend/actions/workflows/analyze.yml) @@ -16,8 +16,8 @@ Bundled integration of preferred frontend tech, for CodeIgniter 4 ### Asset Libraries -* [AdminLTE](https://adminlte.io) - Admin Dashboard Template -* [Bootstrap](https://getbootstrap.com) - Mobile-first front-end CSS framework directed at responsive web development +* [AdminLTE](https://adminlte.io) (via [Tatter\AdminLTE](https://packagist.org/packages/tatter/adminlte)) - Admin Dashboard Template +* [Bootstrap](https://getbootstrap.com) (via [Tatter\Bootstrap](https://packagist.org/packages/tatter/bootstrap)) - Mobile-first front-end CSS framework directed at responsive web development * [ChartJS](https://www.chartjs.org) - Simple yet flexible JavaScript charting for designers & developers * [DataTables](https://datatables.net) - To enhance the accessibility of data in HTML tables * [Dropzone](https://www.dropzonejs.com) - Open source library for drag’n’drop file uploads with image previews @@ -25,10 +25,10 @@ Bundled integration of preferred frontend tech, for CodeIgniter 4 ### Support Libraries -* [League/CommonMark](https://packagist.org/packages/league/commonmark) -* [Tatter/Assets](https://packagist.org/packages/tatter/assets) -* [Tatter/Menus](https://packagist.org/packages/tatter/menus) -* [Tatter/Themes](https://packagist.org/packages/tatter/themes) +* [League\CommonMark](https://packagist.org/packages/league/commonmark) +* [Tatter\Assets](https://packagist.org/packages/tatter/assets) +* [Tatter\Menus](https://packagist.org/packages/tatter/menus) +* [Tatter\Themes](https://packagist.org/packages/tatter/themes) ## Change Log diff --git a/src/Bundles/ChartJSBundle.php b/src/Bundles/ChartJSBundle.php index c55ddd7..dbf8e51 100644 --- a/src/Bundles/ChartJSBundle.php +++ b/src/Bundles/ChartJSBundle.php @@ -8,8 +8,6 @@ class ChartJSBundle extends VendorBundle { /** * Applies any initial inputs after the constructor. - * - * @return void */ protected function define(): void { diff --git a/src/Bundles/DropzoneJSBundle.php b/src/Bundles/DropzoneJSBundle.php index 683834d..42f4b56 100644 --- a/src/Bundles/DropzoneJSBundle.php +++ b/src/Bundles/DropzoneJSBundle.php @@ -8,13 +8,11 @@ class DropzoneJSBundle extends VendorBundle { /** * Applies any initial inputs after the constructor. - * - * @return void */ protected function define(): void { $this - ->addPath('dropzone/dropzone.min.css') - ->addPath('dropzone/dropzone.min.js'); + ->addPath('dropzone/dropzone.min.css') + ->addPath('dropzone/dropzone.min.js'); } } diff --git a/src/Bundles/FontAwesomeBundle.php b/src/Bundles/FontAwesomeBundle.php index 5e8c7bc..53c96c7 100644 --- a/src/Bundles/FontAwesomeBundle.php +++ b/src/Bundles/FontAwesomeBundle.php @@ -8,8 +8,6 @@ class FontAwesomeBundle extends VendorBundle { /** * Applies any initial inputs after the constructor. - * - * @return void */ protected function define(): void { diff --git a/src/Publishers/ChartJSPublisher.php b/src/Publishers/ChartJSPublisher.php index 3ea9cae..c6edba2 100644 --- a/src/Publishers/ChartJSPublisher.php +++ b/src/Publishers/ChartJSPublisher.php @@ -19,18 +19,16 @@ class ChartJSPublisher extends VendorPublisher * Reads files from the sources and copies them out to their destinations. * This method should be reimplemented by child classes intended for * discovery. - * - * @return boolean */ public function publish(): bool { return $this - ->addUri('https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.3.2/chart.min.js') - ->addUri('https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.3.2/chart.esm.js') - ->addUri('https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.3.2/chart.esm.min.js') - ->addUri('https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.3.2/chart.js') - ->addUri('https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.3.2/helpers.esm.js') - ->addUri('https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.3.2/helpers.esm.min.js') - ->copy(true); + ->addUri('https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.3.2/chart.min.js') + ->addUri('https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.3.2/chart.esm.js') + ->addUri('https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.3.2/chart.esm.min.js') + ->addUri('https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.3.2/chart.js') + ->addUri('https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.3.2/helpers.esm.js') + ->addUri('https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.3.2/helpers.esm.min.js') + ->copy(true); } } diff --git a/src/Publishers/DropzoneJSPublisher.php b/src/Publishers/DropzoneJSPublisher.php index a2ceac1..82ea76d 100644 --- a/src/Publishers/DropzoneJSPublisher.php +++ b/src/Publishers/DropzoneJSPublisher.php @@ -24,13 +24,11 @@ class DropzoneJSPublisher extends VendorPublisher * Reads files from the sources and copies them out to their destinations. * This method should be reimplemented by child classes intended for * discovery. - * - * @return boolean */ public function publish(): bool { return $this - ->addPath('/') - ->copy(true); + ->addPath('/') + ->copy(true); } } diff --git a/src/Publishers/FontAwesomePublisher.php b/src/Publishers/FontAwesomePublisher.php index c16c12a..46d0818 100644 --- a/src/Publishers/FontAwesomePublisher.php +++ b/src/Publishers/FontAwesomePublisher.php @@ -24,14 +24,12 @@ class FontAwesomePublisher extends VendorPublisher * Reads files from the sources and copies them out to their destinations. * This method should be reimplemented by child classes intended for * discovery. - * - * @return boolean */ public function publish(): bool { return $this - ->addPath('css') - ->addPath('webfonts') - ->merge(true); + ->addPath('css') + ->addPath('webfonts') + ->merge(true); } } diff --git a/tests/ClassesTest.php b/tests/ClassesTest.php new file mode 100644 index 0000000..4f7bfb0 --- /dev/null +++ b/tests/ClassesTest.php @@ -0,0 +1,89 @@ +publish(); + + $this->assertSame([], $publisher->getErrors()); + $this->assertNotSame([], $publisher->getPublished()); + + foreach ($paths as $path) + { + $file = $this->root->url() . '/vendor/' . $path; + $this->assertFileExists($file); + } + + $bundle = new $bundle(); + $output = (string) $bundle; + + foreach ($files as $file) { + $this->assertStringContainsString($file, $output); + } + } + + public function inputProvider(): array + { + return [ + [ + ChartJSPublisher::class, + [ + 'chartjs/chart.min.js', + 'chartjs/chart.js', + 'chartjs/helpers.esm.min.js', + ], + ChartJSBundle::class, + [ + 'chart.min.js', + ], + ], + [ + DropzoneJSPublisher::class, + [ + 'dropzone/basic.min.css', + 'dropzone/dropzone.css', + 'dropzone/dropzone.min.js', + ], + DropzoneJSBundle::class, + [ + 'dropzone/dropzone.min.css', + 'dropzone/dropzone.min.js', + ], + ], + [ + FontAwesomePublisher::class, + [ + 'font-awesome/css/all.min.css', + 'font-awesome/css/svg-with-js.css', + 'font-awesome/webfonts/fa-brands-400.eot', + 'font-awesome/webfonts/fa-solid-900.woff2', + ], + FontAwesomeBundle::class, + [ + 'font-awesome/css/all.min.css', + ], + ], + ]; + } +} diff --git a/tests/PublishersTest.php b/tests/PublishersTest.php deleted file mode 100644 index da8bcbd..0000000 --- a/tests/PublishersTest.php +++ /dev/null @@ -1,70 +0,0 @@ -publish(); - - $this->assertSame([], $publisher->getErrors()); - $this->assertNotSame([], $publisher->getPublished()); - - foreach ($paths as $path) - { - $file = $this->root->url() . '/vendor/' . $path; - $this->assertFileExists($file); - } - $this->assertNull(null); - } - - /** - * @return array - */ - public function publishersProvider(): array - { - return [ - [ - ChartJSPublisher::class, - [ - 'chartjs/chart.min.js', - 'chartjs/chart.js', - 'chartjs/helpers.esm.min.js', - ], - ], - [ - DropzoneJSPublisher::class, - [ - 'dropzone/basic.min.css', - 'dropzone/dropzone.css', - 'dropzone/dropzone.min.js', - ], - ], - [ - FontAwesomePublisher::class, - [ - 'font-awesome/css/all.min.css', - 'font-awesome/css/svg-with-js.css', - 'font-awesome/webfonts/fa-brands-400.eot', - 'font-awesome/webfonts/fa-solid-900.woff2', - ], - ], - ]; - } -} diff --git a/tests/_support/FrontendTestCase.php b/tests/_support/FrontendTestCase.php deleted file mode 100644 index 87b5957..0000000 --- a/tests/_support/FrontendTestCase.php +++ /dev/null @@ -1,37 +0,0 @@ -config = $this->config ?? config(AssetsConfig::class); - $this->config->useTimestamps = false; // These make testing much harder - - Asset::useConfig($this->config); - } - - /** - * Removes the config. - */ - protected function tearDown(): void - { - parent::tearDown(); - - $this->config = null; - } -} diff --git a/tests/_support/TestCase.php b/tests/_support/TestCase.php new file mode 100644 index 0000000..6de4f02 --- /dev/null +++ b/tests/_support/TestCase.php @@ -0,0 +1,44 @@ +root = vfsStream::setup('root'); + + // Create the config (if a trait has not already) + $this->config = Asset::config(); + $this->config->directory = $this->root->url() . DIRECTORY_SEPARATOR; + $this->config->useTimestamps = false; // These make testing much harder + + Asset::useConfig($this->config); + + // Add VFS as an allowed Publisher directory + config('Publisher')->restrictions[$this->config->directory] = '*'; + } +} diff --git a/tests/_support/VfsTrait.php b/tests/_support/VfsTrait.php deleted file mode 100644 index e5b7ef4..0000000 --- a/tests/_support/VfsTrait.php +++ /dev/null @@ -1,44 +0,0 @@ -root === null) - { - $this->root = vfsStream::setup('root'); - } - - // Create the config (if another trait has not already) - $this->config = $this->config ?? config(AssetsConfig::class); - $this->config->directory = $this->root->url(); - - // Add this as an allowed Publisher directory - config('Publisher')->restrictions[$this->config->directory] = '*'; - } - - /** - * Removes the VFS. - */ - protected function tearDownVfsTrait(): void - { - if (empty($this->persist)) - { - $this->root = null; - } - } -}