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
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -16,19 +16,19 @@ 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
* [FontAwesome](https://fontawesome.com) - Popular icon set and toolkit for vector icons and social logos

### 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

2 changes: 0 additions & 2 deletions src/Bundles/ChartJSBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ class ChartJSBundle extends VendorBundle
{
/**
* Applies any initial inputs after the constructor.
*
* @return void
*/
protected function define(): void
{
Expand Down
6 changes: 2 additions & 4 deletions src/Bundles/DropzoneJSBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
2 changes: 0 additions & 2 deletions src/Bundles/FontAwesomeBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ class FontAwesomeBundle extends VendorBundle
{
/**
* Applies any initial inputs after the constructor.
*
* @return void
*/
protected function define(): void
{
Expand Down
16 changes: 7 additions & 9 deletions src/Publishers/ChartJSPublisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
6 changes: 2 additions & 4 deletions src/Publishers/DropzoneJSPublisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
8 changes: 3 additions & 5 deletions src/Publishers/FontAwesomePublisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
89 changes: 89 additions & 0 deletions tests/ClassesTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php

use Tatter\Frontend\Bundles\ChartJSBundle;
use Tatter\Frontend\Bundles\DropzoneJSBundle;
use Tatter\Frontend\Bundles\FontAwesomeBundle;
use Tatter\Frontend\Publishers\ChartJSPublisher;
use Tatter\Frontend\Publishers\DropzoneJSPublisher;
use Tatter\Frontend\Publishers\FontAwesomePublisher;
use Tests\Support\TestCase;

/**
* Verifies that the Publishers and Bundles behave as expected.
*
* @internal
*/
final class ClassesTest extends TestCase
{
/**
* @param string[] $paths
* @param string[] $files
*
* @dataProvider inputProvider
*/
public function testPublish(string $publisher, array $paths, string $bundle, array $files)
{
$publisher = new $publisher();
$publisher->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',
],
],
];
}
}
70 changes: 0 additions & 70 deletions tests/PublishersTest.php

This file was deleted.

37 changes: 0 additions & 37 deletions tests/_support/FrontendTestCase.php

This file was deleted.

44 changes: 44 additions & 0 deletions tests/_support/TestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace Tests\Support;

use CodeIgniter\Test\CIUnitTestCase;
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamDirectory;
use Tatter\Assets\Asset;
use Tatter\Assets\Config\Assets as AssetsConfig;

abstract class TestCase extends CIUnitTestCase
{
/**
* Virtual workspace
*
* @var vfsStreamDirectory
*/
protected $root;

/**
* @var AssetsConfig
*/
protected $config;

/**
* Preps the config and VFS.
*/
protected function setUp(): void
{
parent::setUp();

$this->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] = '*';
}
}
Loading