Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Commit

Permalink
add homestead as dev-dependency and add kernel stub for HTTP tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix Huber committed Jun 6, 2019
1 parent 4088f0d commit 0867c25
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 8 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"orchestra/database" : "~3.5",
"phpunit/phpunit": "~6.0",
"spatie/phpunit-watcher": "^1.8",
"codeclimate/php-test-reporter": "^0.4.4"
"codeclimate/php-test-reporter": "^0.4.4",
"laravel/homestead": "^8.5"
},
"conflict": {
"herpaderpaldent/seat-notifications": "<2.0.0"
Expand Down
13 changes: 6 additions & 7 deletions tests/SeatGroupIndexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@

class SeatGroupIndexTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testExample()

/** @test */
public function redirectsToLoginIfUnauthorized()
{
$this->assertTrue(true);
$response = $this->get(route('seatgroups.index'));

$response->assertRedirect('auth/login');
}
}
24 changes: 24 additions & 0 deletions tests/Stubs/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php


namespace Herpaderpaldent\Seat\SeatGroups\Test\Stubs;


use Orchestra\Testbench\Http\Middleware\RedirectIfAuthenticated;
use Seat\Web\Http\Middleware\Authenticate;

class Kernel extends \Orchestra\Testbench\Http\Kernel
{

/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array
*/
protected $routeMiddleware = [
'auth' => Authenticate::class,
'guest' => RedirectIfAuthenticated::class,
];
}
15 changes: 15 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace Herpaderpaldent\Seat\SeatGroups\Test;

use Herpaderpaldent\Seat\SeatGroups\GroupsServiceProvider;
use Herpaderpaldent\Seat\SeatGroups\Test\Stubs\Kernel;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Schema;
use Orchestra\Testbench\TestCase as OrchestraTestCase;
Expand Down Expand Up @@ -67,6 +68,18 @@ protected function setUp()
]);
}

/**
* Resolve application HTTP Kernel implementation.
*
* @param \Illuminate\Foundation\Application $app
* @return void
*/
protected function resolveApplicationHttpKernel($app)
{
$app->singleton('Illuminate\Contracts\Http\Kernel', Kernel::class);
}



/**
* Get application providers.
Expand Down Expand Up @@ -109,6 +122,8 @@ protected function getEnvironmentSetUp($app)
'database' => ':memory:',
'prefix' => '',
]);

//$app['router']->aliasMiddleware('auth', Authenticate::class);
}

}

0 comments on commit 0867c25

Please sign in to comment.