From a7189704876e3d498d6ccd0566ddd3d8337ecf8c Mon Sep 17 00:00:00 2001 From: Martin Krisell Date: Sat, 23 Nov 2019 13:34:57 +0100 Subject: [PATCH] Enable optional customization of route prefix --- .gitignore | 1 + phpunit.xml.dist | 1 + src/DeployedVersionServiceProvider.php | 5 +++-- src/config/deployed-version.php | 3 ++- tests/DeployedVersionTest.php | 10 +++++----- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 24b0946..c126d07 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ vendor **/**.cache build +.phpunit* diff --git a/phpunit.xml.dist b/phpunit.xml.dist index cb8fad9..6a6917f 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -16,5 +16,6 @@ + \ No newline at end of file diff --git a/src/DeployedVersionServiceProvider.php b/src/DeployedVersionServiceProvider.php index 955d398..7d51f19 100644 --- a/src/DeployedVersionServiceProvider.php +++ b/src/DeployedVersionServiceProvider.php @@ -10,13 +10,14 @@ class DeployedVersionServiceProvider extends ServiceProvider { public function boot() { - Route::get('/version', VersionController::class); + Route::get(config('deployed-version.route-prefix') . '/version', VersionController::class); } public function register() { $this->mergeConfigFrom( - __DIR__.'/config/deployed-version.php', 'deployed-version' + __DIR__.'/config/deployed-version.php', + 'deployed-version' ); } } diff --git a/src/config/deployed-version.php b/src/config/deployed-version.php index b38d737..1b0eae9 100644 --- a/src/config/deployed-version.php +++ b/src/config/deployed-version.php @@ -2,4 +2,5 @@ return [ 'version' => env('VERSION', 'NONE'), -]; \ No newline at end of file + 'route-prefix' => env('VERSION_ROUTE_PREFIX', '') +]; diff --git a/tests/DeployedVersionTest.php b/tests/DeployedVersionTest.php index 1d93317..ca29918 100644 --- a/tests/DeployedVersionTest.php +++ b/tests/DeployedVersionTest.php @@ -12,21 +12,21 @@ protected function getPackageProviders($app) } /** @test */ - public function the_version_route_is_added() + public function the_version_route_is_added_and_uses_prefix_set_in_env() { - $this->get('/version')->assertStatus(200); + $this->get('dev-custom/version')->assertStatus(200); } /** @test */ public function the_default_version_is_TESTING_VALUE() { - $this->get('/version')->assertJson(['version' => 'TESTING_VALUE']); + $this->get('dev-custom/version')->assertJson(['version' => 'TESTING_VALUE']); } /** @test */ public function the_version_can_be_set_in_the_environment() { config(['deployed-version.version' => 'NEW_TESTING_VALUE']); - $this->get('/version')->assertJson(['version' => 'NEW_TESTING_VALUE']); + $this->get('dev-custom/version')->assertJson(['version' => 'NEW_TESTING_VALUE']); } -} \ No newline at end of file +}