Skip to content

Commit 8d0011e

Browse files
committed
Move test helper methods to TestCase
1 parent 8c03625 commit 8d0011e

File tree

2 files changed

+52
-37
lines changed

2 files changed

+52
-37
lines changed

tests/TestCase.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,62 @@
33
namespace CodeZero\LocalizedRoutes\Tests;
44

55
use CodeZero\LocalizedRoutes\LocalizedRoutesServiceProvider;
6+
use Illuminate\Support\Collection;
7+
use Illuminate\Support\Facades\Config;
8+
use Illuminate\Support\Facades\Route;
69
use Orchestra\Testbench\TestCase as BaseTestCase;
710

811
abstract class TestCase extends BaseTestCase
912
{
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+
1062
/**
1163
* Get the packages service providers.
1264
*

tests/Unit/Macros/LocalizedRoutesMacroTest.php

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,48 +3,11 @@
33
namespace CodeZero\LocalizedRoutes\Tests\Unit\Macros;
44

55
use CodeZero\LocalizedRoutes\Tests\TestCase;
6-
use Illuminate\Support\Collection;
76
use Illuminate\Support\Facades\App;
8-
use Illuminate\Support\Facades\Config;
97
use Illuminate\Support\Facades\Route;
108

119
class LocalizedRoutesMacroTest extends TestCase
1210
{
13-
protected function setSupportedLocales($locales)
14-
{
15-
Config::set('localized-routes.supported-locales', $locales);
16-
}
17-
18-
/**
19-
* Set the use_locale_middleware config option
20-
*
21-
* @param boolean $value
22-
* @return void
23-
*/
24-
protected function setUseLocaleMiddleware($value)
25-
{
26-
Config::set('localized-routes.use_locale_middleware', $value);
27-
}
28-
29-
/**
30-
* Set the omit_url_prefix_for_locale config option
31-
*
32-
* @param string $value
33-
* @return void
34-
*/
35-
protected function setOmitUrlPrefixForLocale($value)
36-
{
37-
Config::set('localized-routes.omit_url_prefix_for_locale', $value);
38-
}
39-
40-
protected function getRoutes()
41-
{
42-
// Route::has() doesn't seem to be working
43-
// when you create routes on the fly.
44-
// So this is a bit of a workaround...
45-
return new Collection(Route::getRoutes());
46-
}
47-
4811
/** @test */
4912
public function it_registers_a_route_for_each_locale()
5013
{

0 commit comments

Comments
 (0)