diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..8645f4ea --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +language: php +php: + - '7.1' + - '7.2' + +script: vendor/bin/phpunit \ No newline at end of file diff --git a/composer.json b/composer.json index 5513346c..3ee667cf 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,10 @@ "illuminate/support": "^5.7", "webpatser/laravel-uuid": "^3.0" }, + "require-dev": { + "orchestra/testbench": "~3.0", + "laravel/framework": "5.7.*" + }, "autoload": { "psr-4": { "Stancl\\Tenancy\\": "src/" @@ -21,6 +25,11 @@ "src/helpers.php" ] }, + "autoload-dev": { + "psr-4": { + "Stancl\\Tenancy\\Tests\\": "tests/" + } + }, "extra": { "laravel": { "providers": [ diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 00000000..2e630c0b --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,31 @@ + + + + + ./tests + + + + + ./app + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Testing/HttpKernel.php b/src/Testing/HttpKernel.php new file mode 100644 index 00000000..88553ec7 --- /dev/null +++ b/src/Testing/HttpKernel.php @@ -0,0 +1,81 @@ + [ + \App\Http\Middleware\EncryptCookies::class, + \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, + \Illuminate\Session\Middleware\StartSession::class, + // \Illuminate\Session\Middleware\AuthenticateSession::class, + \Illuminate\View\Middleware\ShareErrorsFromSession::class, + \App\Http\Middleware\VerifyCsrfToken::class, + \Illuminate\Routing\Middleware\SubstituteBindings::class, + ], + + 'tenancy' => [ + \Stancl\Tenancy\Middleware\InitializeTenancy::class, + ], + + 'api' => [ + 'throttle:60,1', + 'bindings', + ], + ]; + + /** + * The application's route middleware. + * + * These middleware may be assigned to groups or used individually. + * + * @var array + */ + protected $routeMiddleware = [ + 'auth' => \App\Http\Middleware\Authenticate::class, + 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, + 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, + 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, + 'can' => \Illuminate\Auth\Middleware\Authorize::class, + 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, + 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, + 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, + 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, + + 'tenancy' => \Stancl\Tenancy\Middleware\InitializeTenancy::class, + ]; + + /** + * The priority-sorted list of middleware. + * + * This forces non-global middleware to always be in the given order. + * + * @var array + */ + protected $middlewarePriority = [ + \Stancl\Tenancy\Middleware\InitializeTenancy::class, + ]; +} diff --git a/tests/HelloWorldTest.php b/tests/HelloWorldTest.php new file mode 100644 index 00000000..f27efce1 --- /dev/null +++ b/tests/HelloWorldTest.php @@ -0,0 +1,11 @@ +assertTrue(true); + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php new file mode 100644 index 00000000..a33d3ad7 --- /dev/null +++ b/tests/TestCase.php @@ -0,0 +1,34 @@ +singleton('Illuminate\Contracts\Http\Kernel', \Stancl\Tenancy\Testing\HttpKernel::class); + } +}