Skip to content

Commit

Permalink
Add support for Laravel 8
Browse files Browse the repository at this point in the history
  • Loading branch information
sebdesign committed Sep 7, 2020
1 parent 31f2f20 commit 6b1cc2b
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
preset: laravel

risky: true

disabled:
- single_class_element_per_statement
- self_accessor
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ matrix:
- php: 7.4
env: LARAVEL=^7.0 TESTBENCH=^5.0 PHPUNIT=~8.5

# Laravel 8.x
- php: 7.3
env: LARAVEL=^8.0 TESTBENCH=^6.0 PHPUNIT=~9.3
- php: 7.4
env: LARAVEL=^8.0 TESTBENCH=^6.0 PHPUNIT=~9.3

before_install:
- phpenv config-rm xdebug.ini
- composer self-update --stable --no-interaction
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to `laravel-sri` will be documented in this file

## 2.2.0 - 2020-09-07

- Add support for Laravel 8

## 2.1.0 - 2020-03-03

- Add support for Laravel 7
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
"type": "library",
"require": {
"php": "^7.1",
"laravel/framework": "^5.5|^6.0|^7.0"
"laravel/framework": "^5.5|^6.0|^7.0|^8.0"
},
"require-dev": {
"phpunit/phpunit": "^6.0|^7.0|^8.0",
"phpunit/phpunit": "^6.0|^7.0|^8.0|^9.3",
"mockery/mockery": "^1.0",
"orchestra/testbench": "^3.5|^4.0|^5.0"
"orchestra/testbench": "^3.5|^4.0|^5.0|^6.0"
},
"autoload": {
"files": [
Expand Down
42 changes: 42 additions & 0 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,48 @@

use Sebdesign\SRI\Hasher;

if (! function_exists('elixir')) {
/**
* Get the path to a versioned Elixir file.
*
* @param string $file
* @param string $buildDirectory
* @return string
*
* @throws \InvalidArgumentException
*
* @deprecated Use Laravel Mix instead.
*/
function elixir($file, $buildDirectory = 'build')
{
static $manifest = [];
static $manifestPath;

if (empty($manifest) || $manifestPath !== $buildDirectory) {
$path = public_path($buildDirectory.'/rev-manifest.json');

if (file_exists($path)) {
$manifest = json_decode(file_get_contents($path), true);
$manifestPath = $buildDirectory;
}
}

$file = ltrim($file, '/');

if (isset($manifest[$file])) {
return '/'.trim($buildDirectory.'/'.$manifest[$file], '/');
}

$unversioned = public_path($file);

if (file_exists($unversioned)) {
return '/'.trim($file, '/');
}

throw new InvalidArgumentException("File {$file} not defined in asset manifest.");
}
}

if (! function_exists('integrity')) {
/**
* Get the integrity hash for a file.
Expand Down
9 changes: 5 additions & 4 deletions tests/HasherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Sebdesign\SRI\Test;

use PHPUnit\Framework\Constraint\RegularExpression;
use Sebdesign\SRI\Hasher;

class HasherTest extends TestCase
Expand Down Expand Up @@ -109,15 +110,15 @@ public function it_accepts_multiple_algorithms()

// assert

$this->assertRegExp('/^sha256-.+ sha384-.+$/', $hash);
$this->assertThat($hash, new RegularExpression('/^sha256-.+ sha384-.+$/'));

// act

$hash = $hasher->make($css, ['algorithms' => ['sha384', 'sha512']]);

// assert

$this->assertRegExp('/^sha384-.+ sha512-.+$/', $hash);
$this->assertThat($hash, new RegularExpression('/^sha384-.+ sha512-.+$/'));
}

/**
Expand All @@ -138,15 +139,15 @@ public function it_accepts_a_different_delimiter()

// assert

$this->assertRegExp('/^sha256-.+_sha384-.+$/', $hash);
$this->assertThat($hash, new RegularExpression('/^sha256-.+_sha384-.+$/'));

// act

$hash = $hasher->make($css, ['delimiter' => ':']);

// assert

$this->assertRegExp('/^sha256-.+:sha384-.+$/', $hash);
$this->assertThat($hash, new RegularExpression('/^sha256-.+:sha384-.+$/'));
}

/**
Expand Down

0 comments on commit 6b1cc2b

Please sign in to comment.