Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix building the tree, raise coverage to 100%, minor refactoring (#143)
- Loading branch information
Showing
14 changed files
with
370 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" backupGlobals="false" colors="true" verbose="true" bootstrap="vendor/autoload.php" failOnRisky="true" failOnWarning="true"> | ||
<coverage> | ||
<include> | ||
<directory>./</directory> | ||
</include> | ||
<exclude> | ||
<directory>./tests</directory> | ||
<directory>./vendor</directory> | ||
</exclude> | ||
</coverage> | ||
<php> | ||
<ini name="error_reporting" value="-1"/> | ||
</php> | ||
<testsuites> | ||
<testsuite name="Yii Router tests"> | ||
<directory>./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<phpunit | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
verbose="true" | ||
failOnRisky="true" | ||
failOnWarning="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
stopOnFailure="false" | ||
executionOrder="random" | ||
resolveDependencies="true" | ||
> | ||
<php> | ||
<ini name="error_reporting" value="-1"/> | ||
</php> | ||
|
||
<testsuites> | ||
<testsuite name="Yii Router tests"> | ||
<directory>./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<coverage> | ||
<include> | ||
<directory>./src</directory> | ||
<directory>./config</directory> | ||
</include> | ||
</coverage> | ||
</phpunit> |
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
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,56 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Router\Tests; | ||
|
||
use Nyholm\Psr7\Uri; | ||
use PHPUnit\Framework\TestCase; | ||
use Yiisoft\Di\Container; | ||
use Yiisoft\Di\ContainerConfig; | ||
use Yiisoft\Di\StateResetter; | ||
use Yiisoft\Router\CurrentRoute; | ||
use Yiisoft\Router\Route; | ||
use Yiisoft\Router\RouteCollector; | ||
use Yiisoft\Router\RouteCollectorInterface; | ||
|
||
final class ConfigTest extends TestCase | ||
{ | ||
public function testRouteCollector(): void | ||
{ | ||
$container = $this->createContainer(); | ||
|
||
$routerCollector = $container->get(RouteCollectorInterface::class); | ||
$this->assertInstanceOf(RouteCollector::class, $routerCollector); | ||
} | ||
|
||
public function testCurrentRoute(): void | ||
{ | ||
$container = $this->createContainer(); | ||
|
||
$currentRoute = $container->get(CurrentRoute::class); | ||
$currentRoute->setRouteWithArguments(Route::get('/main'), ['name' => 'hello']); | ||
$currentRoute->setUri(new Uri('http://example.com/')); | ||
|
||
$container->get(StateResetter::class)->reset(); | ||
|
||
$this->assertNull($currentRoute->getName()); | ||
$this->assertNull($currentRoute->getUri()); | ||
$this->assertSame([], $currentRoute->getArguments()); | ||
} | ||
|
||
private function createContainer(): Container | ||
{ | ||
return new Container( | ||
ContainerConfig::create()->withDefinitions( | ||
$this->getCommonDefinitions() | ||
) | ||
); | ||
} | ||
|
||
private function getCommonDefinitions(): array | ||
{ | ||
$params = []; | ||
return require dirname(__DIR__) . '/config/common.php'; | ||
} | ||
} |
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
Oops, something went wrong.