|
3 | 3 | namespace CodeZero\LocalizedRoutes\Tests; |
4 | 4 |
|
5 | 5 | use CodeZero\LocalizedRoutes\LocalizedRoutesServiceProvider; |
| 6 | +use Illuminate\Support\Collection; |
| 7 | +use Illuminate\Support\Facades\Config; |
| 8 | +use Illuminate\Support\Facades\Route; |
6 | 9 | use Orchestra\Testbench\TestCase as BaseTestCase; |
7 | 10 |
|
8 | 11 | abstract class TestCase extends BaseTestCase |
9 | 12 | { |
| 13 | + /** |
| 14 | + * Set the supported locales config option. |
| 15 | + * |
| 16 | + * @param $locales |
| 17 | + * |
| 18 | + * @return void |
| 19 | + */ |
| 20 | + protected function setSupportedLocales($locales) |
| 21 | + { |
| 22 | + Config::set('localized-routes.supported-locales', $locales); |
| 23 | + } |
| 24 | + |
| 25 | + /** |
| 26 | + * Set the 'omit_url_prefix_for_locale' config option. |
| 27 | + * |
| 28 | + * @param string $value |
| 29 | + * |
| 30 | + * @return void |
| 31 | + */ |
| 32 | + protected function setOmitUrlPrefixForLocale($value) |
| 33 | + { |
| 34 | + Config::set('localized-routes.omit_url_prefix_for_locale', $value); |
| 35 | + } |
| 36 | + |
| 37 | + /** |
| 38 | + * Set the use_locale_middleware config option |
| 39 | + * |
| 40 | + * @param boolean $value |
| 41 | + * |
| 42 | + * @return void |
| 43 | + */ |
| 44 | + protected function setUseLocaleMiddleware($value) |
| 45 | + { |
| 46 | + Config::set('localized-routes.use_locale_middleware', $value); |
| 47 | + } |
| 48 | + |
| 49 | + /** |
| 50 | + * Get the currently registered routes. |
| 51 | + * |
| 52 | + * @return \Illuminate\Support\Collection |
| 53 | + */ |
| 54 | + protected function getRoutes() |
| 55 | + { |
| 56 | + // Route::has() doesn't seem to be working |
| 57 | + // when you create routes on the fly. |
| 58 | + // So this is a bit of a workaround... |
| 59 | + return new Collection(Route::getRoutes()); |
| 60 | + } |
| 61 | + |
10 | 62 | /** |
11 | 63 | * Get the packages service providers. |
12 | 64 | * |
|
0 commit comments