Skip to content

Commit a718970

Browse files
committed
Enable optional customization of route prefix
1 parent 1aaf3c3 commit a718970

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

.gitignore

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

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616
</testsuites>
1717
<php>
1818
<env name="VERSION" value="TESTING_VALUE"/>
19+
<env name="VERSION_ROUTE_PREFIX" value="dev-custom"/>
1920
</php>
2021
</phpunit>

src/DeployedVersionServiceProvider.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ class DeployedVersionServiceProvider extends ServiceProvider
1010
{
1111
public function boot()
1212
{
13-
Route::get('/version', VersionController::class);
13+
Route::get(config('deployed-version.route-prefix') . '/version', VersionController::class);
1414
}
1515

1616
public function register()
1717
{
1818
$this->mergeConfigFrom(
19-
__DIR__.'/config/deployed-version.php', 'deployed-version'
19+
__DIR__.'/config/deployed-version.php',
20+
'deployed-version'
2021
);
2122
}
2223
}

src/config/deployed-version.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33
return [
44
'version' => env('VERSION', 'NONE'),
5-
];
5+
'route-prefix' => env('VERSION_ROUTE_PREFIX', '')
6+
];

tests/DeployedVersionTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ protected function getPackageProviders($app)
1212
}
1313

1414
/** @test */
15-
public function the_version_route_is_added()
15+
public function the_version_route_is_added_and_uses_prefix_set_in_env()
1616
{
17-
$this->get('/version')->assertStatus(200);
17+
$this->get('dev-custom/version')->assertStatus(200);
1818
}
1919

2020
/** @test */
2121
public function the_default_version_is_TESTING_VALUE()
2222
{
23-
$this->get('/version')->assertJson(['version' => 'TESTING_VALUE']);
23+
$this->get('dev-custom/version')->assertJson(['version' => 'TESTING_VALUE']);
2424
}
2525

2626
/** @test */
2727
public function the_version_can_be_set_in_the_environment()
2828
{
2929
config(['deployed-version.version' => 'NEW_TESTING_VALUE']);
30-
$this->get('/version')->assertJson(['version' => 'NEW_TESTING_VALUE']);
30+
$this->get('dev-custom/version')->assertJson(['version' => 'NEW_TESTING_VALUE']);
3131
}
32-
}
32+
}

0 commit comments

Comments
 (0)