Skip to content

Commit 6b1cc2b

Browse files
committed
Add support for Laravel 8
1 parent 31f2f20 commit 6b1cc2b

File tree

6 files changed

+62
-7
lines changed

6 files changed

+62
-7
lines changed

.styleci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
preset: laravel
22

3+
risky: true
4+
35
disabled:
46
- single_class_element_per_statement
57
- self_accessor

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ matrix:
5151
- php: 7.4
5252
env: LARAVEL=^7.0 TESTBENCH=^5.0 PHPUNIT=~8.5
5353

54+
# Laravel 8.x
55+
- php: 7.3
56+
env: LARAVEL=^8.0 TESTBENCH=^6.0 PHPUNIT=~9.3
57+
- php: 7.4
58+
env: LARAVEL=^8.0 TESTBENCH=^6.0 PHPUNIT=~9.3
59+
5460
before_install:
5561
- phpenv config-rm xdebug.ini
5662
- composer self-update --stable --no-interaction

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

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

5+
## 2.2.0 - 2020-09-07
6+
7+
- Add support for Laravel 8
8+
59
## 2.1.0 - 2020-03-03
610

711
- Add support for Laravel 7

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
"type": "library",
1010
"require": {
1111
"php": "^7.1",
12-
"laravel/framework": "^5.5|^6.0|^7.0"
12+
"laravel/framework": "^5.5|^6.0|^7.0|^8.0"
1313
},
1414
"require-dev": {
15-
"phpunit/phpunit": "^6.0|^7.0|^8.0",
15+
"phpunit/phpunit": "^6.0|^7.0|^8.0|^9.3",
1616
"mockery/mockery": "^1.0",
17-
"orchestra/testbench": "^3.5|^4.0|^5.0"
17+
"orchestra/testbench": "^3.5|^4.0|^5.0|^6.0"
1818
},
1919
"autoload": {
2020
"files": [

src/helpers.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,48 @@
22

33
use Sebdesign\SRI\Hasher;
44

5+
if (! function_exists('elixir')) {
6+
/**
7+
* Get the path to a versioned Elixir file.
8+
*
9+
* @param string $file
10+
* @param string $buildDirectory
11+
* @return string
12+
*
13+
* @throws \InvalidArgumentException
14+
*
15+
* @deprecated Use Laravel Mix instead.
16+
*/
17+
function elixir($file, $buildDirectory = 'build')
18+
{
19+
static $manifest = [];
20+
static $manifestPath;
21+
22+
if (empty($manifest) || $manifestPath !== $buildDirectory) {
23+
$path = public_path($buildDirectory.'/rev-manifest.json');
24+
25+
if (file_exists($path)) {
26+
$manifest = json_decode(file_get_contents($path), true);
27+
$manifestPath = $buildDirectory;
28+
}
29+
}
30+
31+
$file = ltrim($file, '/');
32+
33+
if (isset($manifest[$file])) {
34+
return '/'.trim($buildDirectory.'/'.$manifest[$file], '/');
35+
}
36+
37+
$unversioned = public_path($file);
38+
39+
if (file_exists($unversioned)) {
40+
return '/'.trim($file, '/');
41+
}
42+
43+
throw new InvalidArgumentException("File {$file} not defined in asset manifest.");
44+
}
45+
}
46+
547
if (! function_exists('integrity')) {
648
/**
749
* Get the integrity hash for a file.

tests/HasherTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Sebdesign\SRI\Test;
44

5+
use PHPUnit\Framework\Constraint\RegularExpression;
56
use Sebdesign\SRI\Hasher;
67

78
class HasherTest extends TestCase
@@ -109,15 +110,15 @@ public function it_accepts_multiple_algorithms()
109110

110111
// assert
111112

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

114115
// act
115116

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

118119
// assert
119120

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

123124
/**
@@ -138,15 +139,15 @@ public function it_accepts_a_different_delimiter()
138139

139140
// assert
140141

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

143144
// act
144145

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

147148
// assert
148149

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

152153
/**

0 commit comments

Comments
 (0)