Skip to content

Commit

Permalink
Adjust to router changes (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
rustamwin committed Aug 18, 2021
1 parent 14a98bc commit 9dccc68
Show file tree
Hide file tree
Showing 17 changed files with 29 additions and 85 deletions.
1 change: 1 addition & 0 deletions src/Collector/CommandCollector.php
Expand Up @@ -8,6 +8,7 @@
use Symfony\Component\Console\Event\ConsoleErrorEvent;
use Symfony\Component\Console\Event\ConsoleEvent;
use Symfony\Component\Console\Event\ConsoleTerminateEvent;

use function get_class;
use function is_object;

Expand Down
1 change: 1 addition & 0 deletions src/Collector/EventCollector.php
Expand Up @@ -6,6 +6,7 @@

use Yiisoft\Yii\Console\Event\ApplicationStartup as ConsoleApplicationStartup;
use Yiisoft\Yii\Web\Event\ApplicationStartup as WebApplicationStartup;

use function get_class;

final class EventCollector implements EventCollectorInterface
Expand Down
1 change: 1 addition & 0 deletions src/Collector/RequestCollector.php
Expand Up @@ -6,6 +6,7 @@

use Yiisoft\Yii\Web\Event\AfterRequest;
use Yiisoft\Yii\Web\Event\BeforeRequest;

use function is_object;

final class RequestCollector implements CollectorInterface, IndexCollectorInterface
Expand Down
1 change: 1 addition & 0 deletions src/Collector/WebAppInfoCollector.php
Expand Up @@ -7,6 +7,7 @@
use Yiisoft\Yii\Web\Event\AfterEmit;
use Yiisoft\Yii\Web\Event\AfterRequest;
use Yiisoft\Yii\Web\Event\BeforeRequest;

use function is_object;

final class WebAppInfoCollector implements CollectorInterface, IndexCollectorInterface
Expand Down
27 changes: 0 additions & 27 deletions src/Proxy/ContainerDelegator.php

This file was deleted.

1 change: 1 addition & 0 deletions src/Proxy/ContainerInterfaceProxy.php
Expand Up @@ -9,6 +9,7 @@
use Psr\Container\ContainerInterface;
use Yiisoft\Proxy\ProxyManager;
use Yiisoft\Proxy\ProxyTrait;

use function is_callable;
use function is_object;
use function is_string;
Expand Down
1 change: 1 addition & 0 deletions src/Proxy/ContainerProxyConfig.php
Expand Up @@ -6,6 +6,7 @@

use Psr\EventDispatcher\EventDispatcherInterface;
use Yiisoft\Yii\Debug\Collector\ServiceCollectorInterface;

use function in_array;
use function is_callable;

Expand Down
1 change: 1 addition & 0 deletions src/Proxy/ProxyLogTrait.php
Expand Up @@ -5,6 +5,7 @@
namespace Yiisoft\Yii\Debug\Proxy;

use Yiisoft\Yii\Debug\Event\ProxyMethodCallEvent;

use function get_class;

trait ProxyLogTrait
Expand Down
18 changes: 0 additions & 18 deletions src/Proxy/UrlMatcherInterfaceProxy.php
Expand Up @@ -5,9 +5,7 @@
namespace Yiisoft\Yii\Debug\Proxy;

use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\UriInterface;
use Yiisoft\Router\MatchingResult;
use Yiisoft\Router\Route;
use Yiisoft\Router\UrlMatcherInterface;
use Yiisoft\Yii\Debug\Collector\RouterCollectorInterface;

Expand All @@ -30,20 +28,4 @@ public function match(ServerRequestInterface $request): MatchingResult

return $result;
}

/**
* @codeCoverageIgnore
*/
public function getCurrentRoute(): ?Route
{
return $this->urlMatcher->getCurrentRoute();
}

/**
* @codeCoverageIgnore
*/
public function getCurrentUri(): ?UriInterface
{
return $this->urlMatcher->getCurrentUri();
}
}
1 change: 1 addition & 0 deletions src/Storage/MemoryStorage.php
Expand Up @@ -6,6 +6,7 @@

use Yiisoft\Yii\Debug\Collector\CollectorInterface;
use Yiisoft\Yii\Debug\DebuggerIdGenerator;

use function get_class;

final class MemoryStorage implements StorageInterface
Expand Down
4 changes: 2 additions & 2 deletions tests/Collector/MiddlewareCollectorTest.php
Expand Up @@ -6,11 +6,11 @@

use Nyholm\Psr7\Response;
use Nyholm\Psr7\ServerRequest;
use Yiisoft\Middleware\Dispatcher\Event\AfterMiddleware;
use Yiisoft\Middleware\Dispatcher\Event\BeforeMiddleware;
use Yiisoft\Yii\Debug\Collector\CollectorInterface;
use Yiisoft\Yii\Debug\Collector\MiddlewareCollector;
use Yiisoft\Yii\Debug\Tests\Support\DummyMiddleware;
use Yiisoft\Middleware\Dispatcher\Event\AfterMiddleware;
use Yiisoft\Middleware\Dispatcher\Event\BeforeMiddleware;

final class MiddlewareCollectorTest extends CollectorTestCase
{
Expand Down
3 changes: 2 additions & 1 deletion tests/Collector/RouterCollectorTest.php
Expand Up @@ -9,6 +9,7 @@
use Yiisoft\Router\Route;
use Yiisoft\Router\RouteCollection;
use Yiisoft\Router\RouteCollectionInterface;
use Yiisoft\Router\RouteCollector;
use Yiisoft\Router\RouteCollectorInterface;
use Yiisoft\Router\UrlMatcherInterface;
use Yiisoft\Yii\Debug\Collector\CollectorInterface;
Expand Down Expand Up @@ -38,7 +39,7 @@ protected function collectTestData(CollectorInterface $collector): void
protected function getCollector(): CollectorInterface
{
$this->routeCollector = $this->createMock(RouteCollectorInterface::class);
$routeCollector = Group::create();
$routeCollector = new RouteCollector();
$routeCollector->addGroup(Group::create()->routes(...$this->createRoutes()));

$this->container = new Container(
Expand Down
7 changes: 4 additions & 3 deletions tests/DebugServiceProviderTest.php
Expand Up @@ -21,7 +21,8 @@ final class DebugServiceProviderTest extends TestCase
/**
* @throws \Yiisoft\Factory\Exception\InvalidConfigException
*
* @covers \Yiisoft\Yii\Debug\DebugServiceProvider::register()
* @covers \Yiisoft\Yii\Debug\DebugServiceProvider::getDefinitions()
* @covers \Yiisoft\Yii\Debug\DebugServiceProvider::getExtensions()
*/
public function testRegister(): void
{
Expand All @@ -31,9 +32,9 @@ public function testRegister(): void
LoggerInterface::class => NullLogger::class,
EventDispatcherInterface::class => Dispatcher::class,
ListenerProviderInterface::class => Provider::class,
]
],
[$provider]
);
$provider->register($container);

$this->assertInstanceOf(LoggerInterfaceProxy::class, $container->get(LoggerInterface::class));
$this->assertInstanceOf(EventDispatcherInterfaceProxy::class, $container->get(EventDispatcherInterface::class));
Expand Down
3 changes: 2 additions & 1 deletion tests/DumperTest.php
Expand Up @@ -6,8 +6,8 @@

use PHPUnit\Framework\TestCase;
use stdClass;
use Yiisoft\Yii\Debug\Dumper;
use Yiisoft\Yii\Debug as D;
use Yiisoft\Yii\Debug\Dumper;

final class DumperTest extends TestCase
{
Expand All @@ -16,6 +16,7 @@ final class DumperTest extends TestCase
*
* @param mixed $var
* @param string $expectedResult
*
* @group JOM
*/
public function testAsJsonObjectsMap($var, $expectedResult): void
Expand Down
27 changes: 0 additions & 27 deletions tests/Proxy/ContainerProxyTest.php

This file was deleted.

6 changes: 5 additions & 1 deletion tests/Proxy/UrlMatcherInterfaceProxyTest.php
Expand Up @@ -6,18 +6,22 @@

use Nyholm\Psr7\ServerRequest;
use PHPUnit\Framework\TestCase;
use Yiisoft\Router\CurrentRoute;
use Yiisoft\Router\FastRoute\UrlMatcher;
use Yiisoft\Router\Group;
use Yiisoft\Router\Route;
use Yiisoft\Router\RouteCollection;
use Yiisoft\Router\RouteCollector;
use Yiisoft\Yii\Debug\Collector\RouterCollectorInterface;
use Yiisoft\Yii\Debug\Proxy\UrlMatcherInterfaceProxy;

class UrlMatcherInterfaceProxyTest extends TestCase
{
public function testMatch(): void
{
$matcher = new UrlMatcher(new RouteCollection(Group::create()->routes(Route::get('/'))));
$routeCollector = new RouteCollector();
$routeCollector->addGroup(Group::create()->routes(Route::get('/')));
$matcher = new UrlMatcher(new RouteCollection($routeCollector), new CurrentRoute());
$collector = $this->createMock(RouterCollectorInterface::class);
$time = microtime(true);

Expand Down
11 changes: 6 additions & 5 deletions tests/ProxyServiceProviderTest.php
Expand Up @@ -13,15 +13,16 @@
use Yiisoft\Di\Container;
use Yiisoft\EventDispatcher\Dispatcher\Dispatcher;
use Yiisoft\EventDispatcher\Provider\Provider;
use Yiisoft\Yii\Debug\Proxy\ContainerProxy;
use Yiisoft\Yii\Debug\Proxy\ContainerInterfaceProxy;
use Yiisoft\Yii\Debug\ProxyServiceProvider;

final class ProxyServiceProviderTest extends TestCase
{
/**
* @throws \Yiisoft\Factory\Exception\InvalidConfigException
*
* @covers \Yiisoft\Yii\Debug\ProxyServiceProvider::register()
* @covers \Yiisoft\Yii\Debug\ProxyServiceProvider::getDefinitions()
* @covers \Yiisoft\Yii\Debug\ProxyServiceProvider::getExtensions()
*/
public function testRegister(): void
{
Expand All @@ -31,10 +32,10 @@ public function testRegister(): void
LoggerInterface::class => NullLogger::class,
EventDispatcherInterface::class => Dispatcher::class,
ListenerProviderInterface::class => Provider::class,
]
],
[$provider]
);
$provider->register($container);

$this->assertInstanceOf(ContainerProxy::class, $container->get(ContainerInterface::class));
$this->assertInstanceOf(ContainerInterfaceProxy::class, $container->get(ContainerInterface::class));
}
}

0 comments on commit 9dccc68

Please sign in to comment.