Skip to content

Commit d6c6b89

Browse files
committed
Update test config for Laravel 5 & 6
1 parent e9ad3d0 commit d6c6b89

File tree

5 files changed

+82
-37
lines changed

5 files changed

+82
-37
lines changed

.gitignore

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

.travis.yml

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,46 @@
11
language: php
22

3-
php:
4-
- 7.0
5-
- 7.1
6-
- 7.2
3+
matrix:
4+
include:
5+
- php: 7.0
6+
env: ILLUMINATE_VERSION=5.5.* TESTBENCH_VERSION=3.5.*
7+
- php: 7.1
8+
env: ILLUMINATE_VERSION=5.8.* TESTBENCH_VERSION=3.8.*
9+
- php: 7.1
10+
env: ILLUMINATE_VERSION=5.7.* TESTBENCH_VERSION=3.7.*
11+
- php: 7.1
12+
env: ILLUMINATE_VERSION=5.6.* TESTBENCH_VERSION=3.6.*
13+
- php: 7.2
14+
env: ILLUMINATE_VERSION=6.* TESTBENCH_VERSION=4.*
15+
- php: 7.2
16+
env: ILLUMINATE_VERSION=5.8.* TESTBENCH_VERSION=3.8.*
17+
- php: 7.2
18+
env: ILLUMINATE_VERSION=5.7.* TESTBENCH_VERSION=3.7.*
19+
- php: 7.2
20+
env: ILLUMINATE_VERSION=5.6.* TESTBENCH_VERSION=3.6.*
21+
- php: 7.3
22+
env: ILLUMINATE_VERSION=6.* TESTBENCH_VERSION=4.*
23+
- php: 7.3
24+
env: ILLUMINATE_VERSION=5.8.* TESTBENCH_VERSION=3.8.*
25+
- php: 7.3
26+
env: ILLUMINATE_VERSION=5.7.* TESTBENCH_VERSION=3.7.*
27+
- php: 7.3
28+
env: ILLUMINATE_VERSION=5.6.* TESTBENCH_VERSION=3.6.*
29+
30+
before_script:
31+
32+
before_install:
33+
- travis_retry composer self-update
34+
- composer require "orchestra/testbench:${TESTBENCH_VERSION}" --no-update --dev
35+
- composer require "illuminate/support:${ILLUMINATE_VERSION}" --no-update
36+
37+
install: composer update --prefer-source --no-interaction
738

839
sudo: false
940

1041
cache:
11-
directories:
12-
- $HOME/.composer/cache
13-
14-
before_script:
15-
- travis_retry composer self-update
16-
- travis_retry composer update --no-interaction
42+
directories:
43+
- $HOME/.composer/cache
1744

1845
script:
19-
- vendor/bin/phpunit
46+
- vendor/bin/phpunit

composer.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515
}
1616
],
1717
"require": {
18-
"php": ">=7.0.0"
18+
"php": ">=7.0"
1919
},
2020
"require-dev": {
21-
"fzaninotto/faker": "~1.4",
22-
"mockery/mockery": "0.9.*",
23-
"orchestra/testbench": "~3.5.0",
24-
"phpunit/phpunit": "~6.0"
21+
"orchestra/testbench": ">=3.5",
22+
"phpunit/phpunit": "^6.0|^7.0|^8.0"
2523
},
2624
"autoload": {
2725
"psr-4": {

tests/StageFrontTest.php

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,12 @@ class StageFrontTest extends TestCase
1616
*/
1717
protected $url;
1818

19-
public function setUp()
19+
/** @test */
20+
public function it_redirects_to_a_login_screen_when_stagefront_is_enabled()
2021
{
21-
parent::setUp();
22-
23-
// Note that changing the URL or middleware config in the tests
24-
// has no effect until you call $this->enableStageFront().
25-
// It is disabled by default so nothing is loaded by default.
2622
$this->url = config('stagefront.url');
27-
2823
$this->registerRoute('/page', 'Some Page');
29-
}
3024

31-
/** @test */
32-
public function it_redirects_to_a_login_screen_when_stagefront_is_enabled()
33-
{
3425
$this->enableStageFront();
3526

3627
$this->get('/page')->assertRedirect($this->url);
@@ -39,18 +30,27 @@ public function it_redirects_to_a_login_screen_when_stagefront_is_enabled()
3930
/** @test */
4031
public function it_does_not_redirect_to_a_login_screen_when_stagefront_is_disabled()
4132
{
33+
$this->url = config('stagefront.url');
34+
$this->registerRoute('/page', 'Some Page');
35+
4236
$this->get('/page')->assertStatus(200)->assertSee('Some Page');
4337
}
4438

4539
/** @test */
4640
public function the_login_route_does_not_exist_when_stagefront_is_disabled()
4741
{
42+
$this->url = config('stagefront.url');
43+
$this->registerRoute('/page', 'Some Page');
44+
4845
$this->get($this->url)->assertStatus(404);
4946
}
5047

5148
/** @test */
5249
public function it_redirects_to_the_intended_url_when_you_provide_valid_credentials()
5350
{
51+
$this->url = config('stagefront.url');
52+
$this->registerRoute('/page', 'Some Page');
53+
5454
config()->set('stagefront.login', 'tester');
5555
config()->set('stagefront.password', 'p4ssw0rd');
5656

@@ -68,6 +68,9 @@ public function it_redirects_to_the_intended_url_when_you_provide_valid_credenti
6868
/** @test */
6969
public function it_does_not_allow_access_when_you_provide_invalid_credentials()
7070
{
71+
$this->url = config('stagefront.url');
72+
$this->registerRoute('/page', 'Some Page');
73+
7174
config()->set('stagefront.login', 'tester');
7275
config()->set('stagefront.password', 'p4ssw0rd');
7376

@@ -86,6 +89,9 @@ public function it_does_not_allow_access_when_you_provide_invalid_credentials()
8689
/** @test */
8790
public function it_redirects_home_if_you_are_already_logged_in()
8891
{
92+
$this->url = config('stagefront.url');
93+
$this->registerRoute('/page', 'Some Page');
94+
8995
$this->enableStageFront();
9096

9197
session()->put('stagefront.unlocked', true);
@@ -96,6 +102,9 @@ public function it_redirects_home_if_you_are_already_logged_in()
96102
/** @test */
97103
public function the_password_may_be_stored_encrypted()
98104
{
105+
$this->url = config('stagefront.url');
106+
$this->registerRoute('/page', 'Some Page');
107+
99108
config()->set('stagefront.login', 'tester');
100109
config()->set('stagefront.password', bcrypt('p4ssw0rd'));
101110
config()->set('stagefront.encrypted', true);
@@ -114,6 +123,9 @@ public function the_password_may_be_stored_encrypted()
114123
/** @test */
115124
public function the_users_in_the_database_can_be_used_for_logging_in()
116125
{
126+
$this->url = config('stagefront.url');
127+
$this->registerRoute('/page', 'Some Page');
128+
117129
$this->loadLaravelMigrations(['--database' => 'testing']);
118130

119131
User::create([
@@ -141,6 +153,9 @@ public function the_users_in_the_database_can_be_used_for_logging_in()
141153
/** @test */
142154
public function you_can_limit_which_database_users_have_access_using_a_comma_separated_string()
143155
{
156+
$this->url = config('stagefront.url');
157+
$this->registerRoute('/page', 'Some Page');
158+
144159
$this->loadLaravelMigrations(['--database' => 'testing']);
145160

146161
User::create([
@@ -186,6 +201,9 @@ public function you_can_limit_which_database_users_have_access_using_a_comma_sep
186201
/** @test */
187202
public function you_can_limit_which_database_users_have_access_using_an_array()
188203
{
204+
$this->url = config('stagefront.url');
205+
$this->registerRoute('/page', 'Some Page');
206+
189207
$this->loadLaravelMigrations(['--database' => 'testing']);
190208

191209
User::create([
@@ -231,6 +249,9 @@ public function you_can_limit_which_database_users_have_access_using_an_array()
231249
/** @test */
232250
public function urls_can_be_ignored_so_access_is_not_denied_by_stagefront()
233251
{
252+
$this->url = config('stagefront.url');
253+
$this->registerRoute('/page', 'Some Page');
254+
234255
$this->registerRoute('/public', 'Public');
235256
$this->registerRoute('/public/route', 'Route');
236257

@@ -245,6 +266,9 @@ public function urls_can_be_ignored_so_access_is_not_denied_by_stagefront()
245266
/** @test */
246267
public function it_throttles_login_attempts()
247268
{
269+
$this->url = config('stagefront.url');
270+
$this->registerRoute('/page', 'Some Page');
271+
248272
$faultyCredentials = [
249273
'login' => 'tester',
250274
'password' => 'invalid',
@@ -264,6 +288,9 @@ public function it_throttles_login_attempts()
264288
/** @test */
265289
public function throttling_login_attempts_can_be_disabled()
266290
{
291+
$this->url = config('stagefront.url');
292+
$this->registerRoute('/page', 'Some Page');
293+
267294
$faultyCredentials = [
268295
'login' => 'tester',
269296
'password' => 'invalid',

tests/TestCase.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,11 @@
33
namespace CodeZero\StageFront\Tests;
44

55
use CodeZero\StageFront\StageFrontServiceProvider;
6+
use Illuminate\Support\Str;
67
use Orchestra\Testbench\TestCase as BaseTestCase;
78

89
abstract class TestCase extends BaseTestCase
910
{
10-
/**
11-
* Setup the test environment.
12-
*/
13-
public function setUp()
14-
{
15-
parent::setUp();
16-
17-
config()->set('app.key', str_random(32));
18-
}
19-
2011
/**
2112
* Define environment setup.
2213
*
@@ -26,6 +17,7 @@ public function setUp()
2617
*/
2718
protected function getEnvironmentSetUp($app)
2819
{
20+
$app['config']->set('app.key', Str::random(32));
2921
$app['config']->set('database.default', 'testing');
3022
$app['config']->set('database.connections.testing', [
3123
'driver' => 'sqlite',

0 commit comments

Comments
 (0)