Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapt configuration group names to Yii conventions (#122)
- Loading branch information
Showing
7 changed files
with
73 additions
and
13 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
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Router\FastRoute\Tests; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Yiisoft\Di\Container; | ||
use Yiisoft\Di\ContainerConfig; | ||
use Yiisoft\Router\FastRoute\UrlGenerator; | ||
use Yiisoft\Router\FastRoute\UrlMatcher; | ||
use Yiisoft\Router\RouteCollectionInterface; | ||
use Yiisoft\Router\UrlGeneratorInterface; | ||
use Yiisoft\Router\UrlMatcherInterface; | ||
|
||
final class ConfigTest extends TestCase | ||
{ | ||
public function testDi(): void | ||
{ | ||
$container = $this->createContainer(); | ||
|
||
$urlGenerator = $container->get(UrlGeneratorInterface::class); | ||
|
||
$this->assertInstanceOf(UrlGenerator::class, $urlGenerator); | ||
} | ||
|
||
public function testDiWeb(): void | ||
{ | ||
$container = $this->createContainer('web'); | ||
|
||
$urlMatcher = $container->get(UrlMatcherInterface::class); | ||
|
||
$this->assertInstanceOf(UrlMatcher::class, $urlMatcher); | ||
} | ||
|
||
private function createContainer(?string $postfix = null): Container | ||
{ | ||
return new Container( | ||
ContainerConfig::create()->withDefinitions( | ||
$this->getDiConfig($postfix) | ||
+ | ||
[ | ||
RouteCollectionInterface::class => $this->createMock(RouteCollectionInterface::class), | ||
] | ||
) | ||
); | ||
} | ||
|
||
private function getDiConfig(?string $postfix = null): array | ||
{ | ||
$params = $this->getParams(); | ||
return require dirname(__DIR__) . '/config/di' . ($postfix !== null ? '-' . $postfix : '') . '.php'; | ||
} | ||
|
||
private function getParams(): array | ||
{ | ||
return require dirname(__DIR__) . '/config/params.php'; | ||
} | ||
} |