-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
076b270
commit 83be0ae
Showing
6 changed files
with
62 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
framework: | ||
secret: 'F00' | ||
default_locale: 'en' | ||
default_locale: es | ||
router: | ||
utf8: true | ||
resource: '%kernel.project_dir%/tests/Functional/app/src/Resources/config/routes.yaml' |
2 changes: 1 addition & 1 deletion
2
tests/Functional/app/src/Resources/config/parameters-unsupported-locale.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
parameters: | ||
app_locales: fr|es | ||
locale: en | ||
locale: es |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
use Braunstetter\LocalizedRoutes\EventSubscriber\LocaleRewriteSubscriber; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | ||
use Symfony\Component\Routing\RouteCollection; | ||
use Symfony\Component\Routing\RouterInterface; | ||
|
||
class UnitTest extends TestCase | ||
{ | ||
|
||
/** | ||
* @throws ReflectionException | ||
*/ | ||
public function test_is_locale_supported() | ||
{ | ||
$routerMock = $this->getMockBuilder(RouterInterface::class)->getMock(); | ||
$routerMock->method('getRouteCollection')->willReturn(new RouteCollection()); | ||
$parameterBagMock = $this->getMockBuilder(ParameterBagInterface::class)->getMock(); | ||
$subscriber = new LocaleRewriteSubscriber($routerMock, $parameterBagMock); | ||
|
||
$this->assertFalse($this->invokeMethod($subscriber, 'isLocaleSupported', [null])); | ||
} | ||
|
||
/** | ||
* Call protected/private method of a class. | ||
* | ||
* @param object &$object Instantiated object that we will run method on. | ||
* @param string $methodName Method names to call | ||
* @param array $parameters Array of parameters to pass into method. | ||
* | ||
* @return mixed Method return. | ||
* @throws ReflectionException | ||
*/ | ||
public function invokeMethod(object $object, string $methodName, array $parameters = array()): mixed | ||
{ | ||
$reflection = new \ReflectionClass(get_class($object)); | ||
$method = $reflection->getMethod($methodName); | ||
$method->setAccessible(true); | ||
|
||
return $method->invokeArgs($object, $parameters); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters