From 513617dc53ffe82a5076fd44b1640f20b17d5588 Mon Sep 17 00:00:00 2001 From: Jordan Mele Date: Sat, 6 Apr 2019 21:35:49 +1100 Subject: [PATCH 1/6] #5 100% test coverage and related enhacements - Stabalised absolute path returned by `Assets::urlPathToAbsolutePath` and hardened against silent failure. - Slightly simplified MIME resolution logic. - Marked usage of `Assets::readSchema` without a respository as the return value. - Removed various bit of dead code. - Fixed silent failure in `gulp-bundle-assets` loading support. --- .appveyor.yml | 2 +- .editorconfig | 9 ++ CHANGELOG.md | 16 +++ README.md | 10 +- STYLE-GUIDE.md => STYLE_GUIDE.md | 0 src/AssetBundles/GulpBundleAssetsBundles.php | 12 +- .../GulpBundleAssetsCompiledBundles.php | 2 +- .../GulpBundleAssetsRawBundles.php | 11 +- src/Assets.php | 20 +-- src/AssetsTemplatePlugin.php | 19 +-- src/Util/MimeType.php | 2 +- .../GulpBundleAssetsCompiledBundlesTest.php | 31 ++++- .../GulpBundleAssetsRawBundlesTest.php | 71 +++++++++- tests/AssetsTest.php | 124 +++++++++++++++++- tests/ServeAsset/SlimServeAssetTest.php | 37 +++++- tests/data/bundle.config.bad-bundle.json | 3 + tests/data/bundle.config.bad-scripts.json | 8 ++ tests/data/bundle.config.bad-styles.json | 11 ++ tests/data/bundle.config.invalid-syntax.json | 11 ++ tests/data/bundle.config.stub.json | 1 + tests/data/bundle.result.bad-scripts.json | 6 + tests/data/bundle.result.bad-styles.json | 6 + tests/data/sprinkles/hawks/assets/mysterious | 1 + 23 files changed, 354 insertions(+), 59 deletions(-) create mode 100644 .editorconfig rename STYLE-GUIDE.md => STYLE_GUIDE.md (100%) create mode 100644 tests/data/bundle.config.bad-bundle.json create mode 100644 tests/data/bundle.config.bad-scripts.json create mode 100644 tests/data/bundle.config.bad-styles.json create mode 100644 tests/data/bundle.config.invalid-syntax.json create mode 100644 tests/data/bundle.config.stub.json create mode 100644 tests/data/bundle.result.bad-scripts.json create mode 100644 tests/data/bundle.result.bad-styles.json create mode 100644 tests/data/sprinkles/hawks/assets/mysterious diff --git a/.appveyor.yml b/.appveyor.yml index e875dbd..34898f3 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,7 +1,7 @@ ## Thanks to Cees-Jan Kiewiet: https://blog.wyrihaximus.net/2016/11/running-php-unit-tests-on-windows-using-appveyor-and-chocolatey/ ## Versioning pattern -version: 5.0.0.{build} +version: 5.0.2.{build} ## Disable unneeded features build: off diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..60ae4c5 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +indent_style = space +indent_size = 4 +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +end_of_line = lf \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index a6174ae..4a3fd2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,23 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [Unknown] + +### Added +- Test coverage for remaining untested source. + +### Changed +- Stabilised absolute path returned by `Assets::urlPathToAbsolutePath` and hardened against silent failure. +- Slightly simplified MIME resolution logic. +- Marked usage of `Assets::readSchema` without a respository as the return value. +- Removed various bit of dead code. + +### Fixed +- Fixed silent failure in `gulp-bundle-assets` loading support. + ## [5.0.1] - 2019-01-13 + +### Changed - Updated Dependencies ## [5.0.0] - 2019-01-12 diff --git a/README.md b/README.md index 59dd162..5d1cb64 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,14 @@ [![Latest Version](https://img.shields.io/github/release/userfrosting/assets.svg)](https://github.com/userfrosting/assets/releases) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE.md) -[![Build Status](https://travis-ci.org/userfrosting/assets.svg?branch=master)](https://travis-ci.org/userfrosting/assets) -[![Windows Build](https://ci.appveyor.com/api/projects/status/02gtbpena70q46q2?svg=true)](https://ci.appveyor.com/project/userfrosting/assets) -[![codecov](https://codecov.io/gh/userfrosting/assets/branch/master/graph/badge.svg)](https://codecov.io/gh/userfrosting/assets) [![Join the chat at https://chat.userfrosting.com/channel/support](https://demo.rocket.chat/images/join-chat.svg)](https://chat.userfrosting.com/channel/support) [![Donate](https://img.shields.io/badge/Open%20Collective-Donate-blue.svg)](https://opencollective.com/userfrosting#backer) +| Branch | Status | +| ------ | ------ | +| master | [![codecov](https://codecov.io/gh/userfrosting/assets/branch/master/graph/badge.svg)](https://codecov.io/gh/userfrosting/userfrosting/branch/master) [![Build Status](https://travis-ci.org/userfrosting/assets.svg?branch=master)](https://travis-ci.org/userfrosting/assets) [![Windows Build](https://ci.appveyor.com/api/projects/status/github/userfrosting/assets?branch=master&svg=true)](https://ci.appveyor.com/project/userfrosting/assets) | +| develop | [![codecov](https://codecov.io/gh/userfrosting/assets/branch/develop/graph/badge.svg)](https://codecov.io/gh/userfrosting/assets/branch/develop) [![Build Status](https://travis-ci.org/userfrosting/assets.svg?branch=develop)](https://travis-ci.org/userfrosting/assets) [![Windows Build](https://ci.appveyor.com/api/projects/status/github/userfrosting/assets?svg=true&branch=develop)](https://ci.appveyor.com/project/userfrosting/assets) | + **Assets** is a library originally created for UserFrosting 4 to make it much easier to reference frontend assets in both production and development contexts. Out of the box it can: @@ -176,6 +178,6 @@ $assetsPlugin = new AssetsTemplatePlugin($assets); ``` -## [Style Guide](STYLE-GUIDE.md) +## [Style Guide](STYLE_GUIDE.md) ## [Testing](RUNNING_TESTS.md) diff --git a/STYLE-GUIDE.md b/STYLE_GUIDE.md similarity index 100% rename from STYLE-GUIDE.md rename to STYLE_GUIDE.md diff --git a/src/AssetBundles/GulpBundleAssetsBundles.php b/src/AssetBundles/GulpBundleAssetsBundles.php index 43c42f3..6037d29 100644 --- a/src/AssetBundles/GulpBundleAssetsBundles.php +++ b/src/AssetBundles/GulpBundleAssetsBundles.php @@ -36,7 +36,7 @@ abstract class GulpBundleAssetsBundles implements AssetBundlesInterface public function __construct($filePath) { if (!is_string($filePath)) { - throw new \InvalidArgumentException('$filePath must of type string but was ' . gettype($filePath)); + throw new \InvalidArgumentException('$filePath must of type string but was ' . gettype($filePath));// @codeCoverageIgnore } // Initalise bundles. @@ -72,7 +72,7 @@ public function getJsBundleAssets($bundleName = '') * Attempts to read the schema file from provided path. * * @param string $path Path to schema file. - * @param bool $useRepository + * @param bool $useRepository Deprecated, will be removed in a future release. Setting this to true is recommended for an easier migration. * @throws FileNotFoundException if file cannot be found. * @throws JsonException if file cannot be parsed as JSON. * @return mixed|Repository Returns file contents parsed by json_decode or a Repository if $useRepository is true. @@ -84,13 +84,18 @@ protected function readSchema($path, $useRepository = false) try { $loader = new YamlFileLoader($path); - return new Repository($loader->load()); + return new Repository($loader->load(false)); } catch (FileNotFoundException $e) { throw new FileNotFoundException('The schema file could not be found.', 0, $e); } catch (JsonException $e) { throw new JsonException('The schema file could not be found.', 0, $e); } } else { + // @codeCoverageIgnoreStart + // This code path exists to facilitate an easier migration to v5 of this package + // It cannot be properly tested here without increasing technical debt substantially and such such it will be removed in the future + trigger_error('Usage of \'readSchema\' with repository result disabled is deprecated and will be removed in future releases.', E_USER_DEPRECATED); + // Read schema without abstractions if (!file_exists($path)) { throw new FileNotFoundException("The schema '$path' could not be found."); @@ -107,6 +112,7 @@ protected function readSchema($path, $useRepository = false) } return $schema; + // @codeCoverageIgnoreEnd } } } diff --git a/src/AssetBundles/GulpBundleAssetsCompiledBundles.php b/src/AssetBundles/GulpBundleAssetsCompiledBundles.php index 75ec562..5e00d8d 100644 --- a/src/AssetBundles/GulpBundleAssetsCompiledBundles.php +++ b/src/AssetBundles/GulpBundleAssetsCompiledBundles.php @@ -9,9 +9,9 @@ namespace UserFrosting\Assets\AssetBundles; +use UserFrosting\Assets\Exception\InvalidBundlesFileException; use UserFrosting\Support\Exception\FileNotFoundException; use UserFrosting\Support\Exception\JsonException; -use UserFrosting\Assets\Exception\InvalidBundlesFileException; /** * Represents a collection of asset bundles, loaded from a gulp-bundle-assets results file. diff --git a/src/AssetBundles/GulpBundleAssetsRawBundles.php b/src/AssetBundles/GulpBundleAssetsRawBundles.php index ebf8c24..1f27eac 100644 --- a/src/AssetBundles/GulpBundleAssetsRawBundles.php +++ b/src/AssetBundles/GulpBundleAssetsRawBundles.php @@ -9,9 +9,9 @@ namespace UserFrosting\Assets\AssetBundles; +use UserFrosting\Assets\Exception\InvalidBundlesFileException; use UserFrosting\Support\Exception\FileNotFoundException; use UserFrosting\Support\Exception\JsonException; -use UserFrosting\Assets\Exception\InvalidBundlesFileException; /** * Represents a collection of asset bundles, loaded from a gulp-bundle-assets configuration file. @@ -36,13 +36,18 @@ public function __construct($path) // Read file $schema = $this->readSchema($path, true); - // Abort if no bundle is specified + // No further processing is needed if bundle key is not present if ($schema['bundle'] === null) { return; } + // Verify bundle key is an object + if (!is_array($schema['bundle'])) { + throw new InvalidBundlesFileException("Encountered issue processing bundle property of schema from file '$path'"); + } + // Process bundles - foreach ($schema['bundle'] as $bundleName => $_) { + foreach (array_keys($schema['bundle']) as $bundleName) { $styles = $schema["bundle.$bundleName.styles"]; if ($styles !== null) { // Attempt to add CSS bundle diff --git a/src/Assets.php b/src/Assets.php index 48f7301..3f4c273 100644 --- a/src/Assets.php +++ b/src/Assets.php @@ -9,10 +9,10 @@ namespace UserFrosting\Assets; -use RocketTheme\Toolbox\ResourceLocator\ResourceLocatorInterface; -use UserFrosting\Support\Util\Util; -use UserFrosting\Support\Exception\FileNotFoundException; use UserFrosting\Assets\AssetBundles\AssetBundlesInterface; +use UserFrosting\Support\Exception\FileNotFoundException; +use UserFrosting\Support\Util\Util; +use UserFrosting\UniformResourceLocator\ResourceLocatorInterface; /** * Facilitates convenient access to assets and asset bundles within PHP code. @@ -21,7 +21,7 @@ * @see AssetsTemplatePlugin for template engine integration. * * @author Alex Weissman (https://alexanderweissman.com) - * @author Jordan Mele + * @author Jordan Mele (https://blog.djmm.me) */ class Assets { @@ -194,14 +194,14 @@ public function urlPathToAbsolutePath($uncleanRelativePath) // Get resource from stream uri $resource = $this->locator->getResource($uri); - // Make path absolute. - $absolutePath = $resource->getAbsolutePath(); + // Make path absolute (and normalise) + $absolutePath = realPath($resource->getAbsolutePath()); // Return path or null depending on existence. - if (file_exists($absolutePath)) { + if ($absolutePath && is_file($absolutePath)) { return $absolutePath; } else { - return; + return null; } } @@ -255,7 +255,7 @@ public function setBaseUrl($baseUrl) { // Make sure it's a string, until php 7.1 if (!is_string($baseUrl)) { - throw new \InvalidArgumentException('$baseUrl must be of type string but was ' . gettype($baseUrl)); + throw new \InvalidArgumentException('$baseUrl must be of type string but was ' . gettype($baseUrl));// @codeCoverageIgnore } // Make sure url ends with a slash @@ -286,7 +286,7 @@ public function setLocatorScheme($locatorScheme) { // Make sure it's a string, until php 7.1 if (!is_string($locatorScheme)) { - throw new \InvalidArgumentException('$locateScheme must be of type string but was ' . gettype($locatorScheme)); + throw new \InvalidArgumentException('$locateScheme must be of type string but was ' . gettype($locatorScheme));// @codeCoverageIgnore } elseif ($locatorScheme == '') { throw new \InvalidArgumentException('$locatorScheme must not be an empty string.'); } diff --git a/src/AssetsTemplatePlugin.php b/src/AssetsTemplatePlugin.php index 3807da5..4e3843b 100644 --- a/src/AssetsTemplatePlugin.php +++ b/src/AssetsTemplatePlugin.php @@ -13,7 +13,7 @@ * Generic plugin for template systems. Provides several convenience methods for linking assets within templates. * * @author Alex Weissman (https://alexanderweissman.com) - * @author Jordan Mele + * @author Jordan Mele (https://blog.djmm.me) * * @todo JS and CSS convenience methods. (not bundles) */ @@ -66,7 +66,7 @@ public function css($bundleName = 'css/main', $attributes = []) $assetsTagged = ''; foreach ($assetPaths as $assetPath) { - $assetsTagged .= $this->makeSelfClosingTag('link', true, array_merge(['href' => $assetPath], $attributes)); + $assetsTagged .= $this->makeSelfClosingTag('link', array_merge(['href' => $assetPath], $attributes)); } return $assetsTagged; @@ -108,28 +108,21 @@ private function convertAttributes(array $attributes) * Generates a self closing tag. * * @param string $tagName Tag name. - * @param bool $closingSlash If a closing slash should be included. Defaults to true. * @param mixed[]|null $attributes Attributes to add to tag. Optional. * @return string */ - private function makeSelfClosingTag($tagName, $closingSlash = true, array $attributes = null) + private function makeSelfClosingTag($tagName, array $attributes = null) { if (!is_string($tagName)) { - throw new \InvalidArgumentException('Expected $tagName to be type string but was ' . gettype($tagName) . '.'); - } - if (!is_bool($closingSlash)) { - throw new \InvalidArgumentException('Expected $closingSlash to be type bool but was ' . gettype($closingSlash) . '.'); + throw new \InvalidArgumentException('Expected $tagName to be type string but was ' . gettype($tagName) . '.'); // @codeCoverageIgnore } $output = "<$tagName"; if ($attributes !== null) { $output .= ' ' . $this->convertAttributes($attributes); } - if ($closingSlash) { - $output .= ' />'; - } else { - $output .= '>'; - } + + $output .= ' />'; return $output; } diff --git a/src/Util/MimeType.php b/src/Util/MimeType.php index 497848f..303a508 100755 --- a/src/Util/MimeType.php +++ b/src/Util/MimeType.php @@ -47,7 +47,7 @@ public static function detectByFilename($filename) { $extension = pathinfo($filename, PATHINFO_EXTENSION); - return empty($extension) ? 'text/plain' : static::detectByFileExtension($extension); + return static::detectByFileExtension($extension); } /** diff --git a/tests/AssetBundles/GulpBundleAssetsCompiledBundlesTest.php b/tests/AssetBundles/GulpBundleAssetsCompiledBundlesTest.php index 648c6b9..a86bc10 100644 --- a/tests/AssetBundles/GulpBundleAssetsCompiledBundlesTest.php +++ b/tests/AssetBundles/GulpBundleAssetsCompiledBundlesTest.php @@ -1,8 +1,9 @@ assertInstanceOf(GulpBundleAssetsCompiledBundles::class, $bundles); return $bundles; } + /** + * Tests GulpBundleAssetsCompiledBundles constructor when a bundle contains an invalid styles property. + */ + public function testConstructInvalidStylesBundle() + { + $this->expectException(InvalidBundlesFileException::class); + new GulpBundleAssetsCompiledBundles(__DIR__ . "/../data/bundle.result.bad-styles.json"); + } + + /** + * Tests GulpBundleAssetsCompiledBundles constructor when a bundle contains an invalid scripts property. + */ + public function testConstructInvalidJsBundle() + { + $this->expectException(InvalidBundlesFileException::class); + new GulpBundleAssetsCompiledBundles(__DIR__ . "/../data/bundle.result.bad-scripts.json"); + } + /** * Tests getCssBundleAssets method. * * @param GulpBundleAssetsCompiledBundles $bundles * @return void * - * @depends testConstructGulpBundleAssetsCompiledBundles + * @depends testConstruct */ public function testGetCssBundleAssets(GulpBundleAssetsCompiledBundles $bundles) { @@ -43,7 +62,7 @@ public function testGetCssBundleAssets(GulpBundleAssetsCompiledBundles $bundles) * @param GulpBundleAssetsCompiledBundles $bundles * @return void * - * @depends testConstructGulpBundleAssetsCompiledBundles + * @depends testConstruct */ public function testGetCssBundleAssetsOutOfRange(GulpBundleAssetsCompiledBundles $bundles) { @@ -57,7 +76,7 @@ public function testGetCssBundleAssetsOutOfRange(GulpBundleAssetsCompiledBundles * @param GulpBundleAssetsCompiledBundles $bundles * @return void * - * @depends testConstructGulpBundleAssetsCompiledBundles + * @depends testConstruct */ public function testGetJsBundleAssets(GulpBundleAssetsCompiledBundles $bundles) { @@ -72,7 +91,7 @@ public function testGetJsBundleAssets(GulpBundleAssetsCompiledBundles $bundles) * @param GulpBundleAssetsCompiledBundles $bundles * @return void * - * @depends testConstructGulpBundleAssetsCompiledBundles + * @depends testConstruct */ public function testGetJsBundleAssetsOutOfRange(GulpBundleAssetsCompiledBundles $bundles) { diff --git a/tests/AssetBundles/GulpBundleAssetsRawBundlesTest.php b/tests/AssetBundles/GulpBundleAssetsRawBundlesTest.php index f15721f..4bafc77 100644 --- a/tests/AssetBundles/GulpBundleAssetsRawBundlesTest.php +++ b/tests/AssetBundles/GulpBundleAssetsRawBundlesTest.php @@ -1,8 +1,11 @@ assertInstanceOf(GulpBundleAssetsRawBundles::class, $bundles); return $bundles; } + /** + * Tests GulpBundleAssetsRawBundles constructor with a config that has no bundles property. + */ + public function testConstructStubConfig() + { + $bundles = new GulpBundleAssetsRawBundles(__DIR__ . "/../data/bundle.config.stub.json"); + $this->assertInstanceOf(GulpBundleAssetsRawBundles::class, $bundles); + } + + /** + * Tests GulpBundleAssetsRawBundles constructor with config containing invalid syntax. + */ + public function testConstructInvalidSyntax() + { + $this->expectException(JsonException::class); + new GulpBundleAssetsRawBundles(__DIR__ . "/../data/bundle.config.invalid-syntax.json"); + } + + /** + * Tests GulpBundleAssetsRawBundles constructor with missing config. + */ + public function testConstructNotFound() + { + $this->expectException(FileNotFoundException::class); + new GulpBundleAssetsRawBundles(__DIR__ . "/../data/bundle.config.not-here.json"); + } + + /** + * Tests GulpBundleAssetsRawBundles constructor when the bundle property is the incorrect type. + */ + public function testConstructInvalidBundlesPropertyType() + { + $this->expectException(InvalidBundlesFileException::class); + new GulpBundleAssetsRawBundles(__DIR__ . "/../data/bundle.config.bad-bundle.json"); + } + + /** + * Tests GulpBundleAssetsRawBundles constructor when a bundle contains an invalid styles property. + */ + public function testConstructInvalidStylesBundle() + { + $this->expectException(InvalidBundlesFileException::class); + new GulpBundleAssetsRawBundles(__DIR__ . "/../data/bundle.config.bad-styles.json"); + } + + /** + * Tests GulpBundleAssetsRawBundles constructor when a bundle contains an invalid scripts property. + */ + public function testConstructInvalidJsBundle() + { + $this->expectException(InvalidBundlesFileException::class); + new GulpBundleAssetsRawBundles(__DIR__ . "/../data/bundle.config.bad-scripts.json"); + } + /** * Tests getCssBundleAssets method. * * @param GulpBundleAssetsRawBundles $bundles * @return void * - * @depends testConstructGulpBundleAssetsRawBundles + * @depends testConstruct */ public function testGetCssBundleAssets(GulpBundleAssetsRawBundles $bundles) { @@ -43,7 +100,7 @@ public function testGetCssBundleAssets(GulpBundleAssetsRawBundles $bundles) * @param GulpBundleAssetsRawBundles $bundles * @return void * - * @depends testConstructGulpBundleAssetsRawBundles + * @depends testConstruct */ public function testGetCssBundleAssetsOutOfRange(GulpBundleAssetsRawBundles $bundles) { @@ -57,7 +114,7 @@ public function testGetCssBundleAssetsOutOfRange(GulpBundleAssetsRawBundles $bun * @param GulpBundleAssetsRawBundles $bundles * @return void * - * @depends testConstructGulpBundleAssetsRawBundles + * @depends testConstruct */ public function testGetJsBundleAssets(GulpBundleAssetsRawBundles $bundles) { @@ -73,11 +130,11 @@ public function testGetJsBundleAssets(GulpBundleAssetsRawBundles $bundles) * @param GulpBundleAssetsRawBundles $bundles * @return void * - * @depends testConstructGulpBundleAssetsRawBundles + * @depends testConstruct */ public function testGetJsBundleAssetsOutOfRange(GulpBundleAssetsRawBundles $bundles) { $this->expectException(\OutOfRangeException::class); $bundles->getJsBundleAssets('owls'); } -} \ No newline at end of file +} diff --git a/tests/AssetsTest.php b/tests/AssetsTest.php index 0d1c30c..5892672 100644 --- a/tests/AssetsTest.php +++ b/tests/AssetsTest.php @@ -1,9 +1,10 @@ basePath = __DIR__ . '/data'; - $this->baseUrl = "https://assets.userfrosting.com/"; + $this->baseUrl = 'https://assets.userfrosting.com/'; $this->locatorScheme = "assets"; $this->locator = new ResourceLocator($this->basePath); $this->locator->registerStream($this->locatorScheme, '', 'assets'); @@ -61,11 +62,15 @@ public function testConstructAssets() public function testGetAbsoluteUrlWithString(Assets $assets) { $url = $assets->getAbsoluteUrl('assets://vendor/bootstrap/js/bootstrap.js'); + + // URL $this->assertEquals($this->baseUrl . 'vendor/bootstrap/js/bootstrap.js', $url); - // Translate it back + // Stream URI $this->assertEquals('assets://vendor/bootstrap/js/bootstrap.js', $assets->urlPathToStreamUri($url)); - $this->assertEquals(__DIR__ . '/data/assets/bootstrap/js/bootstrap.js', $assets->urlPathToAbsolutePath($url)); + + // Absolute path + $this->assertEquals(realpath(__DIR__ . '/data/assets/bootstrap/js/bootstrap.js'), $assets->urlPathToAbsolutePath($url)); } /** @@ -84,6 +89,24 @@ public function testGetAbsoluteUrlWithStringArray(Assets $assets) ]), $this->baseUrl . 'vendor/bootstrap/js/bootstrap.js'); } + /** + * Test invalid string[] parameter for getAbsoluteUrl + * + * @param Assets $assets + * @return void + * + * @depends testConstructAssets + */ + public function testGetAbsoluteUrlWithInvalidStringArray(Assets $assets) + { + $this->expectException(\BadMethodCallException::class); + $assets->getAbsoluteUrl([ + 'assets', + 'vendor/bootstrap/js/bootstrap.js', + 'extra-invalid-entry' + ]); + } + /** * Test non-existent asset getAbsoluteUrl * @@ -94,7 +117,7 @@ public function testGetAbsoluteUrlWithStringArray(Assets $assets) */ public function testGetAbsoluteUrlWithNonExistentFile(Assets $assets) { - $this->expectException(UserFrosting\Support\Exception\FileNotFoundException::class); + $this->expectException(FileNotFoundException::class); $assets->getAbsoluteUrl('assets://vendor/bootstrap/js/faker.js'); } @@ -129,6 +152,20 @@ public function testGetJsBundleAssets(Assets $assets) ]); } + /** + * Tests getJsBundleAssets with a non-existant bundle index. + * + * @param Assets $assets + * @return void + * + * @depends testAddAssetBundles + */ + public function testGetJsBundleAssetsOutOfRange(Assets $assets) + { + $this->expectException(\OutOfRangeException::class); + $assets->getJsBundleAssets("i-don't-exist"); + } + /** * Tests getCssBundleAssets * @@ -143,4 +180,77 @@ public function testGetCssBundleAssets(Assets $assets) $this->baseUrl . 'vendor/bootstrap/css/bootstrap.css' ]); } -} \ No newline at end of file + + /** + * Tests getCssBundleAssets with a non-existant bundle index. + * + * @param Assets $assets + * @return void + * + * @depends testAddAssetBundles + */ + public function testGetCssBundleAssetsOutOfRange(Assets $assets) + { + $this->expectException(\OutOfRangeException::class); + $assets->getCssBundleAssets("i-don't-exist"); + } + + /** + * Tests resetAssetBundles + * + * @param Assets $assets + * @return void + * + * @depends testAddAssetBundles + */ + public function testResetAssetBundles(Assets $assets) + { + $this->assertNotEquals($assets->getAssetBundles(), []); + $assets->resetAssetBundles(); + $this->assertEquals($assets->getAssetBundles(), []); + + } + + /** + * Tests urlPathToAbsolutePath + * + * @param Assets $assets + * @return void + * + * @depends testAddAssetBundles + */ + public function testUrlPathToAbsolutePath(Assets $assets) + { + $this->assertNull($assets->urlPathToAbsolutePath('../i/../don\'t/exist/and/cause/issues')); + } + + /** + * Tests getBaseUri + * + * @param Assets $assets + * @return void + * + * @depends testAddAssetBundles + */ + public function testGetBaseUri(Assets $assets) + { + $this->assertEquals($assets->getBaseUrl(), 'https://assets.userfrosting.com/'); + } + + /** + * Tests setLocatorScheme + * + * @param Assets $assets + * @return void + * + * @depends testAddAssetBundles + */ + public function testSetLocatorScheme(Assets $assets) + { + $assets->setLocatorScheme('foo-bar'); + $this->assertEquals($assets->getLocatorScheme(), 'foo-bar://'); + + $this->expectException(\InvalidArgumentException::class); + $assets->setLocatorScheme(''); + } +} diff --git a/tests/ServeAsset/SlimServeAssetTest.php b/tests/ServeAsset/SlimServeAssetTest.php index 8595141..632ea59 100644 --- a/tests/ServeAsset/SlimServeAssetTest.php +++ b/tests/ServeAsset/SlimServeAssetTest.php @@ -5,7 +5,6 @@ use UserFrosting\Assets\ServeAsset\SlimServeAsset; use UserFrosting\Assets\Assets; use UserFrosting\Assets\AssetLoader; -use Slim\Container; use Slim\Http\Environment; use Slim\Http\Request; use Slim\Http\Response; @@ -15,7 +14,7 @@ */ class SlimServeAssetTest extends TestCase { - /** @var Container */ + /** @var AssetLoader */ private $assetLoader; /** @@ -113,4 +112,36 @@ public function testAssetMatchesExpectations(SlimServeAsset $controller) // Assert correct MIME $this->assertSame($response->getHeader('Content-Type'), ['text/plain']); } -} \ No newline at end of file + + /** + * Test with existent asset. + * + * @param SlimServeAsset $controller + * @return void + * + * @depends testConstructor + */ + public function testAssetOfUnknownType(SlimServeAsset $controller) + { + // Create environment. + $environment = Environment::mock([]); + + // Create request and response objects. + $request = Request::createFromEnvironment($environment); + $response = new Response(); + + // Invoke controller method. + $response = $controller->serveAsset($request, $response, [ + 'url' => 'mysterious' + ]); + + // Assert 200 response + $this->assertSame($response->getStatusCode(), 200); + + // Assert response body matches file + $this->assertSame($response->getBody()->__toString(), file_get_contents(__DIR__ . '/../data/sprinkles/hawks/assets/mysterious')); + + // Assert correct MIME + $this->assertSame($response->getHeader('Content-Type'), ['text/plain']); + } +} diff --git a/tests/data/bundle.config.bad-bundle.json b/tests/data/bundle.config.bad-bundle.json new file mode 100644 index 0000000..fa3e8fa --- /dev/null +++ b/tests/data/bundle.config.bad-bundle.json @@ -0,0 +1,3 @@ +{ + "bundle": true +} \ No newline at end of file diff --git a/tests/data/bundle.config.bad-scripts.json b/tests/data/bundle.config.bad-scripts.json new file mode 100644 index 0000000..ad485bc --- /dev/null +++ b/tests/data/bundle.config.bad-scripts.json @@ -0,0 +1,8 @@ +{ + "bundle": { + "test": { + "scripts": false, + "styles": "vendor/bootstrap/css/bootstrap.css" + } + } +} \ No newline at end of file diff --git a/tests/data/bundle.config.bad-styles.json b/tests/data/bundle.config.bad-styles.json new file mode 100644 index 0000000..adfc7f8 --- /dev/null +++ b/tests/data/bundle.config.bad-styles.json @@ -0,0 +1,11 @@ +{ + "bundle": { + "test": { + "scripts": [ + "vendor/bootstrap/js/bootstrap.js", + "vendor/bootstrap/js/npm.js" + ], + "styles": 256 + } + } +} \ No newline at end of file diff --git a/tests/data/bundle.config.invalid-syntax.json b/tests/data/bundle.config.invalid-syntax.json new file mode 100644 index 0000000..8aa448f --- /dev/null +++ b/tests/data/bundle.config.invalid-syntax.json @@ -0,0 +1,11 @@ +{ + "bundle": { + "test": { + "scripts": [ + "vendor/bootstrap/js/bootstrap.js" + 'vendor/bootstrap/js/npm.js' + ], + "styles": "vendor/bootstrap/css/bootstrap.css" + } + } +} diff --git a/tests/data/bundle.config.stub.json b/tests/data/bundle.config.stub.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/tests/data/bundle.config.stub.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/tests/data/bundle.result.bad-scripts.json b/tests/data/bundle.result.bad-scripts.json new file mode 100644 index 0000000..1dab4ef --- /dev/null +++ b/tests/data/bundle.result.bad-scripts.json @@ -0,0 +1,6 @@ +{ + "test": { + "scripts": [ "test-930fa5c1ee.js" ], + "styles": "test-930fa5c1ee.css" + } +} \ No newline at end of file diff --git a/tests/data/bundle.result.bad-styles.json b/tests/data/bundle.result.bad-styles.json new file mode 100644 index 0000000..5178c09 --- /dev/null +++ b/tests/data/bundle.result.bad-styles.json @@ -0,0 +1,6 @@ +{ + "test": { + "scripts": "test-930fa5c1ee.js", + "styles": [ "test-930fa5c1ee.css" ] + } +} \ No newline at end of file diff --git a/tests/data/sprinkles/hawks/assets/mysterious b/tests/data/sprinkles/hawks/assets/mysterious new file mode 100644 index 0000000..0a221b5 --- /dev/null +++ b/tests/data/sprinkles/hawks/assets/mysterious @@ -0,0 +1 @@ +Nobody understands me! From 998ab2e5731bb0339634733ed28bfda1aa0dffa7 Mon Sep 17 00:00:00 2001 From: Louis Charette Date: Sat, 6 Apr 2019 22:34:05 -0400 Subject: [PATCH 2/6] Fix styling --- .php_cs | 4 +- src/AssetBundles/AssetBundlesInterface.php | 11 ++- src/AssetBundles/GulpBundleAssetsBundles.php | 17 ++-- .../GulpBundleAssetsCompiledBundles.php | 8 +- .../GulpBundleAssetsRawBundles.php | 11 ++- src/AssetLoader.php | 10 ++- src/Assets.php | 64 ++++++++------- src/AssetsTemplatePlugin.php | 38 +++++---- src/Exception/InvalidBundlesFileException.php | 5 +- src/ServeAsset/SlimServeAsset.php | 5 +- src/Util/MimeType.php | 8 +- .../GulpBundleAssetsCompiledBundlesTest.php | 25 ++++-- .../GulpBundleAssetsRawBundlesTest.php | 31 +++++--- tests/AssetsTemplatePluginTest.php | 32 +++++--- tests/AssetsTest.php | 78 ++++++++++++------- tests/ServeAsset/SlimServeAssetTest.php | 36 ++++++--- 16 files changed, 247 insertions(+), 136 deletions(-) diff --git a/.php_cs b/.php_cs index d989615..2460568 100644 --- a/.php_cs +++ b/.php_cs @@ -96,13 +96,11 @@ $rules = [ 'header_comment' => [ 'header' => $header, - 'separate' => 'bottom', - 'comment_type' => 'PHPDoc', ] ]; $finder = PhpCsFixer\Finder::create() - ->in([__DIR__ . '/src']); + ->in([__DIR__ . '/src', __DIR__ . '/test']); return PhpCsFixer\Config::create() ->setRules($rules) diff --git a/src/AssetBundles/AssetBundlesInterface.php b/src/AssetBundles/AssetBundlesInterface.php index 59dc57a..b64aac1 100644 --- a/src/AssetBundles/AssetBundlesInterface.php +++ b/src/AssetBundles/AssetBundlesInterface.php @@ -1,5 +1,6 @@ cssBundles[$bundleName][] = $styles; } elseif ($styles !== null) { - throw new InvalidBundlesFileException("Expected styles property for '$bundleName' to be of type string but was '" . gettype($styles) . "' for '$path'"); + throw new InvalidBundlesFileException("Expected styles property for '$bundleName' to be of type string but was '".gettype($styles)."' for '$path'"); } $scripts = $schema["$bundleName.scripts"]; if (is_string($scripts)) { $this->jsBundles[$bundleName][] = $scripts; } elseif ($scripts !== null) { - throw new InvalidBundlesFileException("Expected scripts property for '$bundleName' to be of type string but was '" . gettype($scripts) . "' for '$path'"); + throw new InvalidBundlesFileException("Expected scripts property for '$bundleName' to be of type string but was '".gettype($scripts)."' for '$path'"); } } } diff --git a/src/AssetBundles/GulpBundleAssetsRawBundles.php b/src/AssetBundles/GulpBundleAssetsRawBundles.php index 1f27eac..570dc06 100644 --- a/src/AssetBundles/GulpBundleAssetsRawBundles.php +++ b/src/AssetBundles/GulpBundleAssetsRawBundles.php @@ -1,5 +1,6 @@ getAbsoluteUrl($this->getLocatorScheme() . $asset); + $asset = $this->getAbsoluteUrl($this->getLocatorScheme().$asset); } return $assets; @@ -117,8 +120,10 @@ public function getJsBundleAssets($bundleName) /** * Get asset paths within specified CSS bundle. * - * @param string $bundleName Bundle name. + * @param string $bundleName Bundle name. + * * @throws \OutOfRangeException if specified CSS asset bundle is not found. + * * @return string[] */ public function getCssBundleAssets($bundleName) @@ -138,7 +143,7 @@ public function getCssBundleAssets($bundleName) // Resolve to url foreach ($assets as &$asset) { - $asset = $this->getAbsoluteUrl($this->getLocatorScheme() . $asset); + $asset = $this->getAbsoluteUrl($this->getLocatorScheme().$asset); } return $assets; @@ -149,9 +154,10 @@ public function getCssBundleAssets($bundleName) * Transform a locator uri to a url accessible to a browser * In other words, transform `assets://vendor/bootstrap/js/bootstrap.js` to * `http://example.com/vendor/bootstrap/js/bootstrap.js`, replacing the `://` with the base url - * Make sure the ressource exist in the process + * Make sure the ressource exist in the process. + * + * @param string|array $streamPath The asset uri * - * @param string|array $streamPath The asset uri * @throws \BadMethodCallException * @throws FileNotFoundException */ @@ -175,14 +181,15 @@ public function getAbsoluteUrl($streamPath) // Need to dissociate the scheme from the search query in the stream path $streamPathQuery = Util::stripPrefix($streamPath, $this->getLocatorScheme()); - return $this->baseUrl . $streamPathQuery; + return $this->baseUrl.$streamPathQuery; } /** * Processes a relative path from a URL to an absolute path. Returns null if no file exists at the generated path. * Applies protections against attempts to access restricted files. * - * @param string $uncleanRelativePath Potentially dangerous relative path. + * @param string $uncleanRelativePath Potentially dangerous relative path. + * * @return null|string */ public function urlPathToAbsolutePath($uncleanRelativePath) @@ -195,13 +202,13 @@ public function urlPathToAbsolutePath($uncleanRelativePath) $resource = $this->locator->getResource($uri); // Make path absolute (and normalise) - $absolutePath = realPath($resource->getAbsolutePath()); + $absolutePath = realpath($resource->getAbsolutePath()); // Return path or null depending on existence. if ($absolutePath && is_file($absolutePath)) { return $absolutePath; } else { - return null; + return; } } @@ -209,7 +216,8 @@ public function urlPathToAbsolutePath($uncleanRelativePath) * Processes a relative path from a URL to a locator stream uri. Returns null if no file exists at the generated path. * Applies protections against attempts to access restricted files. * - * @param string $urlPath + * @param string $urlPath + * * @return string */ public function urlPathToStreamUri($urlPath) @@ -224,7 +232,7 @@ public function urlPathToStreamUri($urlPath) $urlPath = Util::stripPrefix($urlPath, $this->baseUrl); // Add back the stream scheme - $uri = $this->getLocatorScheme() . $urlPath; + $uri = $this->getLocatorScheme().$urlPath; // Make sure ressource path exist if (!$this->locator->getResource($uri)) { @@ -235,7 +243,7 @@ public function urlPathToStreamUri($urlPath) } /** - * Returns base Assets base Url + * Returns base Assets base Url. * * @return string */ @@ -245,48 +253,52 @@ public function getBaseUrl() } /** - * Set Asset base Url + * Set Asset base Url. + * + * @param string $baseUrl * - * @param string $baseUrl * @throws \InvalidArgumentException + * * @return $this */ public function setBaseUrl($baseUrl) { // Make sure it's a string, until php 7.1 if (!is_string($baseUrl)) { - throw new \InvalidArgumentException('$baseUrl must be of type string but was ' . gettype($baseUrl));// @codeCoverageIgnore + throw new \InvalidArgumentException('$baseUrl must be of type string but was '.gettype($baseUrl)); // @codeCoverageIgnore } // Make sure url ends with a slash - $baseUrl = rtrim($baseUrl, '/') . '/'; + $baseUrl = rtrim($baseUrl, '/').'/'; $this->baseUrl = $baseUrl; return $this; } /** - * Get Asset Locator Scheme + * Get Asset Locator Scheme. * * @return string */ public function getLocatorScheme() { - return $this->locatorScheme . '://'; + return $this->locatorScheme.'://'; } /** - * Set Asset locator scheme + * Set Asset locator scheme. + * + * @param string $locatorScheme * - * @param string $locatorScheme * @throws \InvalidArgumentException + * * @return $this */ public function setLocatorScheme($locatorScheme) { // Make sure it's a string, until php 7.1 if (!is_string($locatorScheme)) { - throw new \InvalidArgumentException('$locateScheme must be of type string but was ' . gettype($locatorScheme));// @codeCoverageIgnore + throw new \InvalidArgumentException('$locateScheme must be of type string but was '.gettype($locatorScheme)); // @codeCoverageIgnore } elseif ($locatorScheme == '') { throw new \InvalidArgumentException('$locatorScheme must not be an empty string.'); } diff --git a/src/AssetsTemplatePlugin.php b/src/AssetsTemplatePlugin.php index 4e3843b..d78f2ba 100644 --- a/src/AssetsTemplatePlugin.php +++ b/src/AssetsTemplatePlugin.php @@ -1,5 +1,6 @@ $value) { // If $name is not set, then its a value-less attribute. (EG: 'async' and 'defer') - if (is_integer($name)) { + if (is_int($name)) { $output .= "$value "; } else { $output .= "$name=\"$value\" "; @@ -107,19 +111,20 @@ private function convertAttributes(array $attributes) /** * Generates a self closing tag. * - * @param string $tagName Tag name. - * @param mixed[]|null $attributes Attributes to add to tag. Optional. + * @param string $tagName Tag name. + * @param mixed[]|null $attributes Attributes to add to tag. Optional. + * * @return string */ private function makeSelfClosingTag($tagName, array $attributes = null) { if (!is_string($tagName)) { - throw new \InvalidArgumentException('Expected $tagName to be type string but was ' . gettype($tagName) . '.'); // @codeCoverageIgnore + throw new \InvalidArgumentException('Expected $tagName to be type string but was '.gettype($tagName).'.'); // @codeCoverageIgnore } $output = "<$tagName"; if ($attributes !== null) { - $output .= ' ' . $this->convertAttributes($attributes); + $output .= ' '.$this->convertAttributes($attributes); } $output .= ' />'; @@ -130,16 +135,17 @@ private function makeSelfClosingTag($tagName, array $attributes = null) /** * Generates a tag pair. * - * @param string $tagName Tag name. - * @param mixed[]|null $attributes Attributes to add to tag. Optional. - * @param string $content Content generated tags will wrap around. + * @param string $tagName Tag name. + * @param mixed[]|null $attributes Attributes to add to tag. Optional. + * @param string $content Content generated tags will wrap around. + * * @return string */ private function makeRegularTag($tagName, array $attributes = null, $content = '') { $output = "<$tagName"; if ($attributes !== null) { - $output .= ' ' . $this->convertAttributes($attributes); + $output .= ' '.$this->convertAttributes($attributes); } $output .= ">$content"; diff --git a/src/Exception/InvalidBundlesFileException.php b/src/Exception/InvalidBundlesFileException.php index 296b174..8e4110a 100644 --- a/src/Exception/InvalidBundlesFileException.php +++ b/src/Exception/InvalidBundlesFileException.php @@ -1,5 +1,6 @@ 'font/woff', 'woff2' => 'font/woff2', 'ttf' => 'font/ttf', - 'ico' => 'image/x-icon' + 'ico' => 'image/x-icon', ]; } } diff --git a/tests/AssetBundles/GulpBundleAssetsCompiledBundlesTest.php b/tests/AssetBundles/GulpBundleAssetsCompiledBundlesTest.php index a86bc10..9e8ee48 100644 --- a/tests/AssetBundles/GulpBundleAssetsCompiledBundlesTest.php +++ b/tests/AssetBundles/GulpBundleAssetsCompiledBundlesTest.php @@ -1,5 +1,13 @@ assertInstanceOf(GulpBundleAssetsCompiledBundles::class, $bundles); + return $bundles; } @@ -29,7 +38,7 @@ public function testConstruct() public function testConstructInvalidStylesBundle() { $this->expectException(InvalidBundlesFileException::class); - new GulpBundleAssetsCompiledBundles(__DIR__ . "/../data/bundle.result.bad-styles.json"); + new GulpBundleAssetsCompiledBundles(__DIR__.'/../data/bundle.result.bad-styles.json'); } /** @@ -38,13 +47,14 @@ public function testConstructInvalidStylesBundle() public function testConstructInvalidJsBundle() { $this->expectException(InvalidBundlesFileException::class); - new GulpBundleAssetsCompiledBundles(__DIR__ . "/../data/bundle.result.bad-scripts.json"); + new GulpBundleAssetsCompiledBundles(__DIR__.'/../data/bundle.result.bad-scripts.json'); } /** * Tests getCssBundleAssets method. * * @param GulpBundleAssetsCompiledBundles $bundles + * * @return void * * @depends testConstruct @@ -52,7 +62,7 @@ public function testConstructInvalidJsBundle() public function testGetCssBundleAssets(GulpBundleAssetsCompiledBundles $bundles) { $this->assertEquals($bundles->getCssBundleAssets('test'), [ - 'test-930fa5c1ee.css' + 'test-930fa5c1ee.css', ]); } @@ -60,6 +70,7 @@ public function testGetCssBundleAssets(GulpBundleAssetsCompiledBundles $bundles) * Tests that getCssBundleAssets method throws an exception when requested bundle doesn't exist. * * @param GulpBundleAssetsCompiledBundles $bundles + * * @return void * * @depends testConstruct @@ -74,6 +85,7 @@ public function testGetCssBundleAssetsOutOfRange(GulpBundleAssetsCompiledBundles * Tests getJsBundleAssets method. * * @param GulpBundleAssetsCompiledBundles $bundles + * * @return void * * @depends testConstruct @@ -81,7 +93,7 @@ public function testGetCssBundleAssetsOutOfRange(GulpBundleAssetsCompiledBundles public function testGetJsBundleAssets(GulpBundleAssetsCompiledBundles $bundles) { $this->assertEquals($bundles->getJsBundleAssets('test'), [ - 'test-930fa5c1ee.js' + 'test-930fa5c1ee.js', ]); } @@ -89,6 +101,7 @@ public function testGetJsBundleAssets(GulpBundleAssetsCompiledBundles $bundles) * Tests that getJsBundleAssets method throws an exception when requested bundle doesn't exist. * * @param GulpBundleAssetsCompiledBundles $bundles + * * @return void * * @depends testConstruct @@ -98,4 +111,4 @@ public function testGetJsBundleAssetsOutOfRange(GulpBundleAssetsCompiledBundles $this->expectException(\OutOfRangeException::class); $bundles->getJsBundleAssets('owls'); } -} \ No newline at end of file +} diff --git a/tests/AssetBundles/GulpBundleAssetsRawBundlesTest.php b/tests/AssetBundles/GulpBundleAssetsRawBundlesTest.php index 4bafc77..53cae1f 100644 --- a/tests/AssetBundles/GulpBundleAssetsRawBundlesTest.php +++ b/tests/AssetBundles/GulpBundleAssetsRawBundlesTest.php @@ -1,5 +1,13 @@ assertInstanceOf(GulpBundleAssetsRawBundles::class, $bundles); + return $bundles; } @@ -30,7 +39,7 @@ public function testConstruct() */ public function testConstructStubConfig() { - $bundles = new GulpBundleAssetsRawBundles(__DIR__ . "/../data/bundle.config.stub.json"); + $bundles = new GulpBundleAssetsRawBundles(__DIR__.'/../data/bundle.config.stub.json'); $this->assertInstanceOf(GulpBundleAssetsRawBundles::class, $bundles); } @@ -40,7 +49,7 @@ public function testConstructStubConfig() public function testConstructInvalidSyntax() { $this->expectException(JsonException::class); - new GulpBundleAssetsRawBundles(__DIR__ . "/../data/bundle.config.invalid-syntax.json"); + new GulpBundleAssetsRawBundles(__DIR__.'/../data/bundle.config.invalid-syntax.json'); } /** @@ -49,7 +58,7 @@ public function testConstructInvalidSyntax() public function testConstructNotFound() { $this->expectException(FileNotFoundException::class); - new GulpBundleAssetsRawBundles(__DIR__ . "/../data/bundle.config.not-here.json"); + new GulpBundleAssetsRawBundles(__DIR__.'/../data/bundle.config.not-here.json'); } /** @@ -58,7 +67,7 @@ public function testConstructNotFound() public function testConstructInvalidBundlesPropertyType() { $this->expectException(InvalidBundlesFileException::class); - new GulpBundleAssetsRawBundles(__DIR__ . "/../data/bundle.config.bad-bundle.json"); + new GulpBundleAssetsRawBundles(__DIR__.'/../data/bundle.config.bad-bundle.json'); } /** @@ -67,7 +76,7 @@ public function testConstructInvalidBundlesPropertyType() public function testConstructInvalidStylesBundle() { $this->expectException(InvalidBundlesFileException::class); - new GulpBundleAssetsRawBundles(__DIR__ . "/../data/bundle.config.bad-styles.json"); + new GulpBundleAssetsRawBundles(__DIR__.'/../data/bundle.config.bad-styles.json'); } /** @@ -76,13 +85,14 @@ public function testConstructInvalidStylesBundle() public function testConstructInvalidJsBundle() { $this->expectException(InvalidBundlesFileException::class); - new GulpBundleAssetsRawBundles(__DIR__ . "/../data/bundle.config.bad-scripts.json"); + new GulpBundleAssetsRawBundles(__DIR__.'/../data/bundle.config.bad-scripts.json'); } /** * Tests getCssBundleAssets method. * * @param GulpBundleAssetsRawBundles $bundles + * * @return void * * @depends testConstruct @@ -90,7 +100,7 @@ public function testConstructInvalidJsBundle() public function testGetCssBundleAssets(GulpBundleAssetsRawBundles $bundles) { $this->assertEquals($bundles->getCssBundleAssets('test'), [ - 'vendor/bootstrap/css/bootstrap.css' + 'vendor/bootstrap/css/bootstrap.css', ]); } @@ -98,6 +108,7 @@ public function testGetCssBundleAssets(GulpBundleAssetsRawBundles $bundles) * Tests that getCssBundleAssets method throws an exception when requested bundle doesn't exist. * * @param GulpBundleAssetsRawBundles $bundles + * * @return void * * @depends testConstruct @@ -112,6 +123,7 @@ public function testGetCssBundleAssetsOutOfRange(GulpBundleAssetsRawBundles $bun * Tests getJsBundleAssets method. * * @param GulpBundleAssetsRawBundles $bundles + * * @return void * * @depends testConstruct @@ -120,7 +132,7 @@ public function testGetJsBundleAssets(GulpBundleAssetsRawBundles $bundles) { $this->assertEquals($bundles->getJsBundleAssets('test'), [ 'vendor/bootstrap/js/bootstrap.js', - 'vendor/bootstrap/js/npm.js' + 'vendor/bootstrap/js/npm.js', ]); } @@ -128,6 +140,7 @@ public function testGetJsBundleAssets(GulpBundleAssetsRawBundles $bundles) * Tests that getJsBundleAssets method throws an exception when requested bundle doesn't exist. * * @param GulpBundleAssetsRawBundles $bundles + * * @return void * * @depends testConstruct diff --git a/tests/AssetsTemplatePluginTest.php b/tests/AssetsTemplatePluginTest.php index 79a0a8c..f6030d3 100644 --- a/tests/AssetsTemplatePluginTest.php +++ b/tests/AssetsTemplatePluginTest.php @@ -1,10 +1,18 @@ basePath = __DIR__ . '/data'; - $this->baseUrl = "https://assets.userfrosting.com/assets/"; - $this->locatorScheme = "assets"; + $this->basePath = __DIR__.'/data'; + $this->baseUrl = 'https://assets.userfrosting.com/assets/'; + $this->locatorScheme = 'assets'; $this->locator = new ResourceLocator($this->basePath); $this->locator->registerStream($this->locatorScheme, '', 'assets'); $this->locator->registerStream($this->locatorScheme, 'vendor', 'assets', true); $this->locator->registerLocation('hawks', 'sprinkles/hawks/'); $this->locator->registerLocation('owls', 'sprinkles/owls/'); $this->assets = new Assets($this->locator, $this->locatorScheme, $this->baseUrl); - $this->assets->addAssetBundles(new GulpBundleAssetsRawBundles(__DIR__ . "/data/bundle.config.json")); + $this->assets->addAssetBundles(new GulpBundleAssetsRawBundles(__DIR__.'/data/bundle.config.json')); } /** @@ -50,6 +58,7 @@ public function testConstructAssetsTemplatePlugin() { $plugin = new AssetsTemplatePlugin($this->assets); $this->assertInstanceOf(AssetsTemplatePlugin::class, $plugin); + return $plugin; } @@ -57,6 +66,7 @@ public function testConstructAssetsTemplatePlugin() * Test JS bundle method. * * @param AssetsTemplatePlugin $plugin + * * @return void * * @depends testConstructAssetsTemplatePlugin @@ -70,6 +80,7 @@ public function testJsBundle(AssetsTemplatePlugin $plugin) * Test JS bundle method with attributes. * * @param AssetsTemplatePlugin $plugin + * * @return void * * @depends testConstructAssetsTemplatePlugin @@ -83,6 +94,7 @@ public function testJsBundleWithAttributes(AssetsTemplatePlugin $plugin) * Test CSS bundle method. * * @param AssetsTemplatePlugin $plugin + * * @return void * * @depends testConstructAssetsTemplatePlugin @@ -96,25 +108,27 @@ public function testCssBundle(AssetsTemplatePlugin $plugin) * Test CSS bundle method with attributes. * * @param AssetsTemplatePlugin $plugin + * * @return void * * @depends testConstructAssetsTemplatePlugin */ public function testCssBundleWithAttributes(AssetsTemplatePlugin $plugin) { - $this->assertEquals($plugin->css('test', ['want-async', 'data-test' => "value"]), ''); + $this->assertEquals($plugin->css('test', ['want-async', 'data-test' => 'value']), ''); } /** * Test url method. * * @param AssetsTemplatePlugin $plugin + * * @return void * * @depends testConstructAssetsTemplatePlugin */ public function testUrl(AssetsTemplatePlugin $plugin) { - $this->assertEquals($plugin->url("assets://vendor/bootstrap/fonts/glyphicons-halflings-regular.eot"), 'https://assets.userfrosting.com/assets/vendor/bootstrap/fonts/glyphicons-halflings-regular.eot'); + $this->assertEquals($plugin->url('assets://vendor/bootstrap/fonts/glyphicons-halflings-regular.eot'), 'https://assets.userfrosting.com/assets/vendor/bootstrap/fonts/glyphicons-halflings-regular.eot'); } -} \ No newline at end of file +} diff --git a/tests/AssetsTest.php b/tests/AssetsTest.php index 5892672..4ac2dbf 100644 --- a/tests/AssetsTest.php +++ b/tests/AssetsTest.php @@ -1,5 +1,13 @@ basePath = __DIR__ . '/data'; + $this->basePath = __DIR__.'/data'; $this->baseUrl = 'https://assets.userfrosting.com/'; - $this->locatorScheme = "assets"; + $this->locatorScheme = 'assets'; $this->locator = new ResourceLocator($this->basePath); $this->locator->registerStream($this->locatorScheme, '', 'assets'); $this->locator->registerStream($this->locatorScheme, 'vendor', 'assets', true); @@ -48,13 +56,15 @@ public function testConstructAssets() { $assets = new Assets($this->locator, $this->locatorScheme, $this->baseUrl); $this->assertInstanceOf(Assets::class, $assets); + return $assets; } /** - * Test string parameter for getAbsoluteUrl + * Test string parameter for getAbsoluteUrl. * * @param Assets $assets + * * @return void * * @depends testConstructAssets @@ -64,19 +74,20 @@ public function testGetAbsoluteUrlWithString(Assets $assets) $url = $assets->getAbsoluteUrl('assets://vendor/bootstrap/js/bootstrap.js'); // URL - $this->assertEquals($this->baseUrl . 'vendor/bootstrap/js/bootstrap.js', $url); + $this->assertEquals($this->baseUrl.'vendor/bootstrap/js/bootstrap.js', $url); // Stream URI $this->assertEquals('assets://vendor/bootstrap/js/bootstrap.js', $assets->urlPathToStreamUri($url)); // Absolute path - $this->assertEquals(realpath(__DIR__ . '/data/assets/bootstrap/js/bootstrap.js'), $assets->urlPathToAbsolutePath($url)); + $this->assertEquals(realpath(__DIR__.'/data/assets/bootstrap/js/bootstrap.js'), $assets->urlPathToAbsolutePath($url)); } /** - * Test string[] parameter for getAbsoluteUrl + * Test string[] parameter for getAbsoluteUrl. * * @param Assets $assets + * * @return void * * @depends testConstructAssets @@ -85,14 +96,15 @@ public function testGetAbsoluteUrlWithStringArray(Assets $assets) { $this->assertEquals($assets->getAbsoluteUrl([ 'assets', - 'vendor/bootstrap/js/bootstrap.js' - ]), $this->baseUrl . 'vendor/bootstrap/js/bootstrap.js'); + 'vendor/bootstrap/js/bootstrap.js', + ]), $this->baseUrl.'vendor/bootstrap/js/bootstrap.js'); } /** - * Test invalid string[] parameter for getAbsoluteUrl + * Test invalid string[] parameter for getAbsoluteUrl. * * @param Assets $assets + * * @return void * * @depends testConstructAssets @@ -103,14 +115,15 @@ public function testGetAbsoluteUrlWithInvalidStringArray(Assets $assets) $assets->getAbsoluteUrl([ 'assets', 'vendor/bootstrap/js/bootstrap.js', - 'extra-invalid-entry' + 'extra-invalid-entry', ]); } /** - * Test non-existent asset getAbsoluteUrl + * Test non-existent asset getAbsoluteUrl. * * @param Assets $assets + * * @return void * * @depends testConstructAssets @@ -125,30 +138,33 @@ public function testGetAbsoluteUrlWithNonExistentFile(Assets $assets) * Tests addition of bundles to Assets instance. * * @param Assets $assets + * * @return Assets * * @depends testConstructAssets */ public function testAddAssetBundles(Assets $assets) { - $assets->addAssetBundles(new GulpBundleAssetsRawBundles(__DIR__ . "/data/bundle.config.json")); + $assets->addAssetBundles(new GulpBundleAssetsRawBundles(__DIR__.'/data/bundle.config.json')); $this->assertInternalType('array', $assets->getAssetBundles()); + return $assets; } /** - * Tests getJsBundleAssets + * Tests getJsBundleAssets. * * @param Assets $assets + * * @return void * * @depends testAddAssetBundles */ public function testGetJsBundleAssets(Assets $assets) { - $this->assertEquals($assets->getJsBundleAssets("test"), [ - $this->baseUrl . 'vendor/bootstrap/js/bootstrap.js', - $this->baseUrl . 'vendor/bootstrap/js/npm.js' + $this->assertEquals($assets->getJsBundleAssets('test'), [ + $this->baseUrl.'vendor/bootstrap/js/bootstrap.js', + $this->baseUrl.'vendor/bootstrap/js/npm.js', ]); } @@ -156,6 +172,7 @@ public function testGetJsBundleAssets(Assets $assets) * Tests getJsBundleAssets with a non-existant bundle index. * * @param Assets $assets + * * @return void * * @depends testAddAssetBundles @@ -167,17 +184,18 @@ public function testGetJsBundleAssetsOutOfRange(Assets $assets) } /** - * Tests getCssBundleAssets + * Tests getCssBundleAssets. * * @param Assets $assets + * * @return void * * @depends testAddAssetBundles */ public function testGetCssBundleAssets(Assets $assets) { - $this->assertEquals($assets->getCssBundleAssets("test"), [ - $this->baseUrl . 'vendor/bootstrap/css/bootstrap.css' + $this->assertEquals($assets->getCssBundleAssets('test'), [ + $this->baseUrl.'vendor/bootstrap/css/bootstrap.css', ]); } @@ -185,6 +203,7 @@ public function testGetCssBundleAssets(Assets $assets) * Tests getCssBundleAssets with a non-existant bundle index. * * @param Assets $assets + * * @return void * * @depends testAddAssetBundles @@ -196,11 +215,12 @@ public function testGetCssBundleAssetsOutOfRange(Assets $assets) } /** - * Tests resetAssetBundles + * Tests resetAssetBundles. * * @param Assets $assets + * * @return void - * + * * @depends testAddAssetBundles */ public function testResetAssetBundles(Assets $assets) @@ -208,15 +228,15 @@ public function testResetAssetBundles(Assets $assets) $this->assertNotEquals($assets->getAssetBundles(), []); $assets->resetAssetBundles(); $this->assertEquals($assets->getAssetBundles(), []); - } /** - * Tests urlPathToAbsolutePath + * Tests urlPathToAbsolutePath. * * @param Assets $assets + * * @return void - * + * * @depends testAddAssetBundles */ public function testUrlPathToAbsolutePath(Assets $assets) @@ -225,11 +245,12 @@ public function testUrlPathToAbsolutePath(Assets $assets) } /** - * Tests getBaseUri + * Tests getBaseUri. * * @param Assets $assets + * * @return void - * + * * @depends testAddAssetBundles */ public function testGetBaseUri(Assets $assets) @@ -238,11 +259,12 @@ public function testGetBaseUri(Assets $assets) } /** - * Tests setLocatorScheme + * Tests setLocatorScheme. * * @param Assets $assets + * * @return void - * + * * @depends testAddAssetBundles */ public function testSetLocatorScheme(Assets $assets) diff --git a/tests/ServeAsset/SlimServeAssetTest.php b/tests/ServeAsset/SlimServeAssetTest.php index 632ea59..8d00b4a 100644 --- a/tests/ServeAsset/SlimServeAssetTest.php +++ b/tests/ServeAsset/SlimServeAssetTest.php @@ -1,13 +1,21 @@ registerStream($locatorScheme, '', 'assets'); $locator->registerStream($locatorScheme, 'vendor', 'assets', true); @@ -49,6 +57,7 @@ public function testConstructor() { $server = new SlimServeAsset($this->assetLoader); $this->assertInstanceOf(SlimServeAsset::class, $server); + return $server; } @@ -56,6 +65,7 @@ public function testConstructor() * Test with non-existent asset. * * @param SlimServeAsset $controller + * * @return void * * @depends testConstructor @@ -71,7 +81,7 @@ public function testInaccessibleAsset(SlimServeAsset $controller) // Invoke controller method. $response = $controller->serveAsset($request, $response, [ - 'url' => 'forbidden.txt' + 'url' => 'forbidden.txt', ]); // Assert 404 response @@ -85,6 +95,7 @@ public function testInaccessibleAsset(SlimServeAsset $controller) * Test with existent asset. * * @param SlimServeAsset $controller + * * @return void * * @depends testConstructor @@ -100,14 +111,14 @@ public function testAssetMatchesExpectations(SlimServeAsset $controller) // Invoke controller method. $response = $controller->serveAsset($request, $response, [ - 'url' => 'allowed.txt' + 'url' => 'allowed.txt', ]); // Assert 200 response $this->assertSame($response->getStatusCode(), 200); // Assert response body matches file - $this->assertSame($response->getBody()->__toString(), file_get_contents(__DIR__ . '/../data/sprinkles/hawks/assets/allowed.txt')); + $this->assertSame($response->getBody()->__toString(), file_get_contents(__DIR__.'/../data/sprinkles/hawks/assets/allowed.txt')); // Assert correct MIME $this->assertSame($response->getHeader('Content-Type'), ['text/plain']); @@ -117,6 +128,7 @@ public function testAssetMatchesExpectations(SlimServeAsset $controller) * Test with existent asset. * * @param SlimServeAsset $controller + * * @return void * * @depends testConstructor @@ -132,14 +144,14 @@ public function testAssetOfUnknownType(SlimServeAsset $controller) // Invoke controller method. $response = $controller->serveAsset($request, $response, [ - 'url' => 'mysterious' + 'url' => 'mysterious', ]); // Assert 200 response $this->assertSame($response->getStatusCode(), 200); // Assert response body matches file - $this->assertSame($response->getBody()->__toString(), file_get_contents(__DIR__ . '/../data/sprinkles/hawks/assets/mysterious')); + $this->assertSame($response->getBody()->__toString(), file_get_contents(__DIR__.'/../data/sprinkles/hawks/assets/mysterious')); // Assert correct MIME $this->assertSame($response->getHeader('Content-Type'), ['text/plain']); From 3446b3c50391329d3e7a16decf2ae54fefd87d20 Mon Sep 17 00:00:00 2001 From: Jordan Mele Date: Sun, 7 Apr 2019 12:43:24 +1000 Subject: [PATCH 3/6] Prepare for v5.0.2 release, doc updates, and style fixes. --- CHANGELOG.md | 2 + README.md | 109 ++++++++++++++++++++------------------------------ composer.json | 3 +- 3 files changed, 47 insertions(+), 67 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a3fd2b..1c84096 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a ## [Unknown] +## [5.0.2] - 2019-04-07 + ### Added - Test coverage for remaining untested source. diff --git a/README.md b/README.md index 5d1cb64..9791f79 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,39 @@ # UserFrosting/Assets -[![Latest Version](https://img.shields.io/github/release/userfrosting/assets.svg)](https://github.com/userfrosting/assets/releases) +[![Latest Version][version-badge]][releases] [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE.md) [![Join the chat at https://chat.userfrosting.com/channel/support](https://demo.rocket.chat/images/join-chat.svg)](https://chat.userfrosting.com/channel/support) [![Donate](https://img.shields.io/badge/Open%20Collective-Donate-blue.svg)](https://opencollective.com/userfrosting#backer) -| Branch | Status | -| ------ | ------ | -| master | [![codecov](https://codecov.io/gh/userfrosting/assets/branch/master/graph/badge.svg)](https://codecov.io/gh/userfrosting/userfrosting/branch/master) [![Build Status](https://travis-ci.org/userfrosting/assets.svg?branch=master)](https://travis-ci.org/userfrosting/assets) [![Windows Build](https://ci.appveyor.com/api/projects/status/github/userfrosting/assets?branch=master&svg=true)](https://ci.appveyor.com/project/userfrosting/assets) | -| develop | [![codecov](https://codecov.io/gh/userfrosting/assets/branch/develop/graph/badge.svg)](https://codecov.io/gh/userfrosting/assets/branch/develop) [![Build Status](https://travis-ci.org/userfrosting/assets.svg?branch=develop)](https://travis-ci.org/userfrosting/assets) [![Windows Build](https://ci.appveyor.com/api/projects/status/github/userfrosting/assets?svg=true&branch=develop)](https://ci.appveyor.com/project/userfrosting/assets) | +| Branch | Status | Coverage | Style | +| ------ | ------ | -------- | ----- | +| [master][master] | [![Build Status][master-build-travis-badge]][travis] [![Windows Build][master-build-appveyor-badge]][appveyor] | [![codecov][master-codecov-badge]][codecov] | [![][master-styleci-badge]][styleci] | +| [develop][develop] | [![Build Status][develop-build-travis-badge]][travis] [![Windows Build][develop-build-appveyor-badge]][appveyor] | [![codecov][develop-codecov-badge]][codecov] | [![][develop-styleci-badge]][styleci] | + + +[codecov]: https://codecov.io/gh/userfrosting/assets +[releases]: https://github.com/userfrosting/assets/releases +[styleci]: https://github.styleci.io/repos/30551954 +[travis]: https://travis-ci.org/userfrosting/assets +[appveyor]: https://ci.appveyor.com/project/userfrosting/assets +[version-badge]: https://img.shields.io/github/release/userfrosting/assets.svg +[master]: https://github.com/userfrosting/assets/tree/master +[master-styleci-badge]: https://github.styleci.io/repos/55460230/shield?branch=master&style=flat +[master-codecov-badge]: https://codecov.io/gh/userfrosting/assets/branch/master/graph/badge.svg +[master-build-travis-badge]: https://travis-ci.org/userfrosting/assets.svg?branch=master +[master-build-appveyor-badge]: https://ci.appveyor.com/api/projects/status/github/userfrosting/assets?branch=master&svg=true +[develop]: https://github.com/userfrosting/assets/tree/develop +[develop-styleci-badge]: https://github.styleci.io/repos/55460230/shield?branch=develop&style=flat +[develop-codecov-badge]: https://codecov.io/gh/userfrosting/assets/branch/develop/graph/badge.svg +[develop-build-travis-badge]: https://travis-ci.org/userfrosting/assets.svg?branch=develop +[develop-build-appveyor-badge]: https://ci.appveyor.com/api/projects/status/github/userfrosting/assets?branch=develop&svg=true **Assets** is a library originally created for UserFrosting 4 to make it much easier to reference frontend assets in both production and development contexts. Out of the box it can: - Provide an easy way to generate an absolute url to an asset via a locator. -- Provide a basic level of integration with *gulp-bundle-assets*, making it easy to reference asset bundles. +- Provide a basic level of integration with [`gulp-bundle-assets`](https://github.com/dowjones/gulp-bundle-assets) and complete integration with [`@userfrosting/gulp-bundle-assets`](https://www.npmjs.com/package/@userfrosting/gulp-bundle-assets), making it easy to reference asset bundles. - Integrate via a common interface with virtually any bundling system. - Integrate with Slim to serve assets that are inaccessible from the public folder, in the development context. - Perform url-to-path transformations. Useful for making debuggable URLs that can be reverted back to the path to be used by the Slim asset server. @@ -53,13 +71,13 @@ $locator->registerStream('assets', '', [ $assets = new Assets($locator, 'assets', $baseUrl); ``` -> Optionally 1 more argument can be passed into the `Assets` constructor. -> - An instance of `PrefixTransformer`. +> Optionally 1 more argument can be passed into the `Assets` constructor, an instance of `PrefixTransformer`. +> > Have a look at UserFrosting in dev mode to see this in action! ### Asset Bundles -To access asset bundles from an `Assets` instance, it must first be passed an instance of `AssetBundlesInterface` via `addAssetBundles`. An example of this follows: +To access asset bundles from an `Assets` instance, it must first be passed an instance of `AssetBundlesInterface` via `addAssetBundles`. The following example demonstates how to integrate with `@userfrosting/gulp-bundle-assets` (and by extension `gulp-bundle-assets`). Note that raw bundles are only supported when their configuration is defined as JSON. *Directory Tree* @@ -78,44 +96,20 @@ To access asset bundles from an `Assets` instance, it must first be passed an in { "bundle": { "js/main": { - "scripts": [ - "js/bootstrap-3.3.1.js", - "js/crud.js" - ], - "options": { - "result": { - "type": { - "scripts": "plain" - } - } - } + "scripts": [ + "js/bootstrap-3.3.1.js", + "js/crud.js" + ] }, "css/main": { - "styles": [ - "vendor/font-awesome-4.5.0/css/font-awesome.css", - "css/bootstrap-3.3.1.css", - "css/bootstrap-custom.css", - "css/paper.css" - ], - "options": { - "result": { - "type": { - "styles": "plain" - } - } - } + "styles": [ + "vendor/font-awesome-4.5.0/css/font-awesome.css", + "css/bootstrap-3.3.1.css", + "css/bootstrap-custom.css", + "css/paper.css" + ] } - }, - "copy": [ - { - "src": "images/**/*", - "base": "." - }, - { - "src": "vendor/font-awesome-4.5.0/fonts/**/*", - "base": "vendor/font-awesome-4.5.0/" - } - ] + } } ``` @@ -125,36 +119,19 @@ To access asset bundles from an `Assets` instance, it must first be passed an in use UserFrosting\Assets\GulpBundleAssetsRawBundles; // Load asset bundles. -$assetBundles = new GulpBundleAssetsRawBundles("../build/asset-bundles.json"); +$assetBundles = new GulpBundleAssetsRawBundles('../build/asset-bundles.json'); // Send loaded asset bundles to Assets instance. $assets->addAssetBundles($assetBundles); // Grab an asset bundle. -$assets->getJsBundleAssets("js/main"); +$assets->getJsBundleAssets('js/main'); // Outputs ["js/bootstrap-3.3.1.js", "js/crud.js"] ``` -See [gulp-bundle-assets](https://github.com/dowjones/gulp-bundle-assets) for how to use the bundler this example demonstrates integration with. - -Just keep in mind that this integration can only work when the gulp-bundle-assets configuration is stored in a separate JSON file, not a JavaScript file. - -Also note the setting of `options -> result -> type -> styles/scripts` for each bundle to `plain`. This is important to do, so that `Assets` can parse the output of `gulp-bundle-assets` and correctly render tags for compiled assets. The output of your Gulp task should look something like: - -*bundle.result.json* - -```json -{ - "js/main": { - "scripts": "js/main-8881456f8e.js" - }, - "css/main": { - "styles": "css/main-c72ce38fba.css" - } -} -``` +Compiled bundles can be used in much the same way, except using `GulpBundleAssetsCompiledBundles` and the bundlers result file. -Using this results file would be done with the `GulpBundleAssetsCompiledBundles` class. +If using the original `gulp-bundle-assets` you'll need to include an additional setting `options->result->type->styles/scripts="plain"` in each bundle. ### The Template Plugin @@ -170,7 +147,7 @@ $assetsPlugin = new AssetsTemplatePlugin($assets); ```twig {# Gets replaced at runtime with the following. Additional argument is optional. #} -{{assets.js("js/main", { defer: true })}} +{{ assets.js("js/main", { defer: true }) }} ``` ```html diff --git a/composer.json b/composer.json index 439aede..27d2107 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,8 @@ }, { "name": "Jordan Mele", - "email": "SiliconSolder@outlook.com.au" + "email": "SiliconSolder@outlook.com.au", + "homepage": "https://blog.djmm.me" } ], "require": { From d255370e36a78857b013b6c3f3de11446689d18a Mon Sep 17 00:00:00 2001 From: Jordan Mele Date: Sun, 7 Apr 2019 12:48:03 +1000 Subject: [PATCH 4/6] Fixed PhpCsFixer --- .php_cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.php_cs b/.php_cs index 2460568..aa9adf0 100644 --- a/.php_cs +++ b/.php_cs @@ -100,7 +100,7 @@ $rules = [ ]; $finder = PhpCsFixer\Finder::create() - ->in([__DIR__ . '/src', __DIR__ . '/test']); + ->in([__DIR__ . '/src', __DIR__ . '/tests']); return PhpCsFixer\Config::create() ->setRules($rules) From 442a481b21d8b83912264bcc00f5be4f29b76509 Mon Sep 17 00:00:00 2001 From: Jordan Mele Date: Sun, 7 Apr 2019 12:50:32 +1000 Subject: [PATCH 5/6] Fix styleci link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9791f79..f30157b 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ [codecov]: https://codecov.io/gh/userfrosting/assets [releases]: https://github.com/userfrosting/assets/releases -[styleci]: https://github.styleci.io/repos/30551954 +[styleci]: https://github.styleci.io/repos/55460230 [travis]: https://travis-ci.org/userfrosting/assets [appveyor]: https://ci.appveyor.com/project/userfrosting/assets [version-badge]: https://img.shields.io/github/release/userfrosting/assets.svg From d3c6cff724a7d1a5289f791264d6c80d0f94f3d0 Mon Sep 17 00:00:00 2001 From: Jordan Mele Date: Sun, 7 Apr 2019 12:52:34 +1000 Subject: [PATCH 6/6] `Status` -> `Build` --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f30157b..107d265 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ [![Join the chat at https://chat.userfrosting.com/channel/support](https://demo.rocket.chat/images/join-chat.svg)](https://chat.userfrosting.com/channel/support) [![Donate](https://img.shields.io/badge/Open%20Collective-Donate-blue.svg)](https://opencollective.com/userfrosting#backer) -| Branch | Status | Coverage | Style | -| ------ | ------ | -------- | ----- | +| Branch | Build | Coverage | Style | +| ------ | ----- | -------- | ----- | | [master][master] | [![Build Status][master-build-travis-badge]][travis] [![Windows Build][master-build-appveyor-badge]][appveyor] | [![codecov][master-codecov-badge]][codecov] | [![][master-styleci-badge]][styleci] | | [develop][develop] | [![Build Status][develop-build-travis-badge]][travis] [![Windows Build][develop-build-appveyor-badge]][appveyor] | [![codecov][develop-codecov-badge]][codecov] | [![][develop-styleci-badge]][styleci] |