Skip to content

Commit 40b86a9

Browse files
authored
Laravel 9 support (#42)
* first draft to support laravel 9 * exclude unsupported versions from test matrix * prepare changelog for release of v2.3.0
1 parent cb96b45 commit 40b86a9

File tree

9 files changed

+41
-23
lines changed

9 files changed

+41
-23
lines changed

.github/workflows/tests.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,16 @@ jobs:
1010
strategy:
1111
fail-fast: false
1212
matrix:
13-
php: [7.3, 7.4, 8.0]
14-
laravel: [6.*, 7.*, 8.*]
13+
php: [7.4, 8.0, 8.1]
14+
laravel: [6.*, 7.*, 8.*, 9.*]
15+
exclude:
16+
# excludes unsupported combinations
17+
- php: 7.4
18+
laravel: 9.*
19+
- php: 8.1
20+
laravel: 6.*
21+
- php: 8.1
22+
laravel: 7.*
1523

1624
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}
1725

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
composer.lock
33
.idea
44
build
5+
.phpunit.result.cache

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog for Laravel Security Checker
22

3+
## v2.3.0 (2022-03-02)
4+
* add support for Laravel 9, PHP 8.1
5+
* dropped support for PHP 7.3, minimum version is now 7.4
6+
37
## v2.2.1 (2021-03-10)
48
FIXED
59
* a permission failure when using this package with multiple users on the same server by adding `temp-dir` to available config options (thanks @thomasderoo4!)

composer.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,20 @@
1717
"require": {
1818
"php": ">=7.2|^8.0",
1919
"guzzlehttp/guzzle": "^7.0",
20-
"laravel/framework": "^6.0|^7.0|^8.0",
20+
"illuminate/support": "^6.0|^7.0|^8.0|^9.0",
21+
"illuminate/console": "^6.0|^7.0|^8.0|^9.0",
22+
"illuminate/bus": "^6.0|^7.0|^8.0|^9.0",
23+
"illuminate/mail": "^6.0|^7.0|^8.0|^9.0",
24+
"illuminate/queue": "^6.0|^7.0|^8.0|^9.0",
25+
"illuminate/notifications": "^6.0|^7.0|^8.0|^9.0",
2126
"ext-json": "*",
2227
"enlightn/security-checker": "^1.3"
2328
},
2429
"require-dev": {
2530
"laravel/slack-notification-channel": "^1.0|^2.0",
2631
"phpunit/phpunit": "^6.0|^7.0|^8.0|^9.0",
27-
"squizlabs/php_codesniffer": "~2.3",
28-
"orchestra/testbench": "^4.0|^5.0|^6.0",
32+
"squizlabs/php_codesniffer": "~2.3|^3.6",
33+
"orchestra/testbench": "^4.0|^5.0|^6.0|^7.0",
2934
"mockery/mockery": "^1.2"
3035
},
3136
"suggest": {

tests/SecurityMailCommandTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class SecurityMailCommandTest extends TestCase
1111
/**
1212
* Tests if the email will be sent
1313
*/
14-
public function testFireMethod()
14+
public function testFireMethod(): void
1515
{
1616
Mail::fake();
1717

@@ -31,7 +31,7 @@ public function testFireMethod()
3131
/**
3232
* Tests if the email will cancel if there are no recipients
3333
*/
34-
public function testFireMethodWithoutRecipients()
34+
public function testFireMethodWithoutRecipients(): void
3535
{
3636
Mail::fake();
3737

@@ -49,7 +49,7 @@ public function testFireMethodWithoutRecipients()
4949
/**
5050
* Tests if the email will cancel if there are no vulnerabilities
5151
*/
52-
public function testFireMethodWithoutVulnerabilities()
52+
public function testFireMethodWithoutVulnerabilities(): void
5353
{
5454
Mail::fake();
5555

@@ -68,7 +68,7 @@ public function testFireMethodWithoutVulnerabilities()
6868
/**
6969
* Tests if the email will cancel if there are no vulnerabilities
7070
*/
71-
public function testFireMethodWithoutVulnerabilitiesWithSending()
71+
public function testFireMethodWithoutVulnerabilitiesWithSending(): void
7272
{
7373
Mail::fake();
7474

tests/SecurityMailTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class SecurityMailTest extends TestCase
1010
/**
1111
* This method tests if the Mailable class gets rendered correctly.
1212
*/
13-
public function testLaravelMailable()
13+
public function testLaravelMailable(): void
1414
{
1515
// create the mailable
1616
$vulnerabilities = $this->getFakeVulnerabilityReport();

tests/SecuritySlackCommandTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class SecuritySlackCommandTest extends TestCase
1717
/**
1818
* Tests if the notification get's sent
1919
*/
20-
public function testHandleMethod()
20+
public function testHandleMethod(): void
2121
{
2222
Notification::fake();
2323

@@ -44,7 +44,7 @@ function ($notification, $channels, $notifiable) {
4444
/**
4545
* Tests that no notification is sent if a Slack Webhook has not been configured.
4646
*/
47-
public function testHandleMethodWithoutSlackWebHook()
47+
public function testHandleMethodWithoutSlackWebHook(): void
4848
{
4949
Notification::fake();
5050

@@ -67,7 +67,7 @@ public function testHandleMethodWithoutSlackWebHook()
6767
/**
6868
* Test that no notification get's sent if there are no vulnerabilities
6969
*/
70-
public function testHandleMethodWithoutVulnerabilities()
70+
public function testHandleMethodWithoutVulnerabilities(): void
7171
{
7272
Notification::fake();
7373

tests/SecuritySlackTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class SecuritySlackTest extends TestCase
99
/**
1010
* This method tests if the SecuritySlackNotification class gets rendered correctly.
1111
*/
12-
public function testSlackNotification()
12+
public function testSlackNotification(): void
1313
{
1414
$vulnerabilities = $this->getFakeVulnerabilityReport();
1515
$composerLockPath = '/path/to/composer.lock';
@@ -19,10 +19,10 @@ public function testSlackNotification()
1919

2020
$generatedNotification = $notification->toSlack();
2121

22-
$this->assertEquals($notification->via()[0], 'slack');
22+
$this->assertEquals('slack', $notification->via()[0]);
2323
$this->assertEquals($notification->toArray(), $vulnerabilities);
2424
$this->assertEquals($generatedNotification->username, config('app.url'));
25-
$this->assertEquals($generatedNotification->content, "*Security Check Report:* `{$composerLockPath}`");
26-
$this->assertEquals(count($generatedNotification->attachments), count($vulnerabilities));
25+
$this->assertEquals("*Security Check Report:* `{$composerLockPath}`", $generatedNotification->content);
26+
$this->assertCount(count($generatedNotification->attachments), $vulnerabilities);
2727
}
2828
}

tests/TestCase.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,24 @@ class TestCase extends \Orchestra\Testbench\TestCase
1111
* @param \Illuminate\Foundation\Application $app
1212
* @return array
1313
*/
14-
protected function getPackageProviders($app)
14+
protected function getPackageProviders($app): array
1515
{
1616
return [ServiceProvider::class];
1717
}
1818

19-
protected function bindPassingSecurityChecker()
19+
protected function bindPassingSecurityChecker(): void
2020
{
2121
$securityCheckerMock = \Mockery::mock(SecurityChecker::class);
22-
$securityCheckerMock->shouldReceive('check')->andReturn([]);
22+
$securityCheckerMock->allows('check')->andReturns([]);
2323

2424
// bind Mockery instance to the app container
2525
$this->app->instance(SecurityChecker::class, $securityCheckerMock);
2626
}
2727

28-
protected function bindFailingSecurityChecker()
28+
protected function bindFailingSecurityChecker(): void
2929
{
3030
$securityCheckerMock = \Mockery::mock(SecurityChecker::class);
31-
$securityCheckerMock->shouldReceive('check')->andReturn($this->getFakeVulnerabilityReport());
31+
$securityCheckerMock->allows('check')->andReturns($this->getFakeVulnerabilityReport());
3232

3333
// bind Mockery instance to the app container
3434
$this->app->instance(SecurityChecker::class, $securityCheckerMock);
@@ -39,7 +39,7 @@ protected function bindFailingSecurityChecker()
3939
*
4040
* @return array
4141
*/
42-
public function getFakeVulnerabilityReport()
42+
public function getFakeVulnerabilityReport(): array
4343
{
4444
return [
4545
'bugsnag/bugsnag-laravel' => [

0 commit comments

Comments
 (0)