-
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.
Merge pull request #3 from Micro-PHP/v1.0.2-release
v1.0.2 released
- Loading branch information
Showing
10 changed files
with
102 additions
and
114 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 |
---|---|---|
|
@@ -2,13 +2,13 @@ | |
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the Micro framework package. | ||
/* | ||
* This file is part of the Micro framework package. | ||
* | ||
* (c) Stanislau Komar <[email protected]> | ||
* (c) Stanislau Komar <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Micro\Plugin\Http\Business\Locator; | ||
|
@@ -22,13 +22,10 @@ | |
*/ | ||
readonly class RouteCodeLocator implements RouteLocatorInterface | ||
{ | ||
/** | ||
* @param KernelInterface $kernel | ||
*/ | ||
public function __construct( | ||
private KernelInterface $kernel | ||
) | ||
{ | ||
private KernelInterface $kernel, | ||
private HttpFacadeInterface $httpFacade | ||
) { | ||
} | ||
|
||
/** | ||
|
@@ -39,9 +36,9 @@ public function locate(): iterable | |
$iterator = $this->kernel->plugins(RouteProviderPluginInterface::class); | ||
/** @var RouteProviderPluginInterface $plugin */ | ||
foreach ($iterator as $plugin) { | ||
foreach ($plugin->provideRoutes() as $route) { | ||
foreach ($plugin->provideRoutes($this->httpFacade) as $route) { | ||
yield $route; | ||
} | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -2,13 +2,13 @@ | |
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the Micro framework package. | ||
/* | ||
* This file is part of the Micro framework package. | ||
* | ||
* (c) Stanislau Komar <[email protected]> | ||
* (c) Stanislau Komar <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Micro\Plugin\Http; | ||
|
@@ -19,6 +19,7 @@ | |
use Micro\Framework\Kernel\Plugin\PluginDependedInterface; | ||
use Micro\Plugin\Http\Business\Locator\RouteCodeLocator; | ||
use Micro\Plugin\Http\Business\Locator\RouteLocatorInterface; | ||
use Micro\Plugin\Http\Facade\HttpFacadeInterface; | ||
use Micro\Plugin\Http\Plugin\HttpRouteLocatorPluginInterface; | ||
|
||
/** | ||
|
@@ -27,7 +28,6 @@ | |
readonly class HttpRouterCodePlugin implements HttpRouteLocatorPluginInterface, DependencyProviderInterface, PluginDependedInterface | ||
{ | ||
/** | ||
* @var Container | ||
* @phpstan-ignore-next-line | ||
*/ | ||
private Container $container; | ||
|
@@ -46,8 +46,9 @@ public function getLocatorType(): string | |
public function createLocator(): RouteLocatorInterface | ||
{ | ||
$kernel = $this->container->get(KernelInterface::class); | ||
$httpFacade = $this->container->get(HttpFacadeInterface::class); | ||
// @phpstan-ignore-next-line | ||
return new RouteCodeLocator($kernel); | ||
return new RouteCodeLocator($kernel, $httpFacade); | ||
} | ||
|
||
/** | ||
|
@@ -59,4 +60,4 @@ public function getDependedPlugins(): iterable | |
HttpCorePlugin::class, | ||
]; | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -2,18 +2,19 @@ | |
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the Micro framework package. | ||
/* | ||
* This file is part of the Micro framework package. | ||
* | ||
* (c) Stanislau Komar <[email protected]> | ||
* (c) Stanislau Komar <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Micro\Plugin\Http\Plugin; | ||
|
||
use Micro\Plugin\Http\Business\Route\RouteInterface; | ||
use Micro\Plugin\Http\Facade\HttpFacadeInterface; | ||
|
||
/** | ||
* @author Stanislau Komar <[email protected]> | ||
|
@@ -23,5 +24,5 @@ interface RouteProviderPluginInterface | |
/** | ||
* @return iterable<RouteInterface> | ||
*/ | ||
public function provideRoutes(): iterable; | ||
} | ||
public function provideRoutes(HttpFacadeInterface $httpFacade): iterable; | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -2,13 +2,13 @@ | |
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the Micro framework package. | ||
/* | ||
* This file is part of the Micro framework package. | ||
* | ||
* (c) Stanislau Komar <[email protected]> | ||
* (c) Stanislau Komar <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Micro\Plugin\Http\Test\Unit; | ||
|
@@ -30,7 +30,7 @@ public function testApp() | |
$kernel = new AppKernel( | ||
$configuration, | ||
[ | ||
TestPlugin::class | ||
HttpTestPlugin::class, | ||
], | ||
); | ||
|
||
|
@@ -40,6 +40,5 @@ public function testApp() | |
->execute($request); | ||
|
||
$this->assertEquals('Hello, kost', $response->getContent()); | ||
|
||
} | ||
} | ||
} |
17 changes: 8 additions & 9 deletions
17
...Business/Locator/RouteCodeLocatorTest.php → ...Business/Locator/RouteCodeLocatorTest.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,38 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Micro framework package. | ||
/* | ||
* This file is part of the Micro framework package. | ||
* | ||
* (c) Stanislau Komar <[email protected]> | ||
* (c) Stanislau Komar <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
|
||
namespace Micro\Plugin\Http\Test\Unit\Business\Locator; | ||
|
||
use Micro\Framework\Kernel\KernelInterface; | ||
use Micro\Plugin\Http\Business\Locator\RouteCodeLocator; | ||
use Micro\Plugin\Http\Business\Route\RouteInterface; | ||
use Micro\Plugin\Http\Facade\HttpFacadeInterface; | ||
use Micro\Plugin\Http\Plugin\RouteProviderPluginInterface; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class RouteCodeLocatorTest extends TestCase | ||
{ | ||
|
||
public function testLocate() | ||
{ | ||
$kernel = $this->createMock(KernelInterface::class); | ||
$httpFacadeMock = $this->createMock(HttpFacadeInterface::class); | ||
$kernel | ||
->expects($this->once()) | ||
->method('plugins') | ||
->with(RouteProviderPluginInterface::class) | ||
->willReturn([ | ||
$this->createRouteProvider(), | ||
$this->createRouteProvider() | ||
]); | ||
|
||
$routerCodeLocator = new RouteCodeLocator($kernel); | ||
$routerCodeLocator = new RouteCodeLocator($kernel, $httpFacadeMock); | ||
foreach ($routerCodeLocator->locate() as $route) { | ||
$this->assertInstanceOf(RouteInterface::class, $route); | ||
} | ||
|
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,12 +1,12 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Micro framework package. | ||
/* | ||
* This file is part of the Micro framework package. | ||
* | ||
* (c) Stanislau Komar <[email protected]> | ||
* (c) Stanislau Komar <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Micro\Plugin\Http\Test\Unit; | ||
|
@@ -15,6 +15,7 @@ | |
use Micro\Framework\Kernel\KernelInterface; | ||
use Micro\Framework\Kernel\Plugin\DependencyProviderInterface; | ||
use Micro\Plugin\Http\Business\Locator\RouteLocatorInterface; | ||
use Micro\Plugin\Http\Facade\HttpFacadeInterface; | ||
use Micro\Plugin\Http\HttpCorePlugin; | ||
use Micro\Plugin\Http\HttpRouterCodePlugin; | ||
use Micro\Plugin\Http\Plugin\HttpRouteLocatorPluginInterface; | ||
|
@@ -25,14 +26,15 @@ class HttpRouterCodePluginTest extends TestCase | |
protected \Micro\Plugin\Http\HttpRouterCodePlugin $plugin; | ||
protected Container $container; | ||
|
||
public function setUp(): void | ||
protected function setUp(): void | ||
{ | ||
$this->container = $this->createMock(Container::class); | ||
$this->plugin = new HttpRouterCodePlugin(); | ||
$this->plugin->provideDependencies($this->container); | ||
} | ||
|
||
public function testConstruct() { | ||
public function testConstruct() | ||
{ | ||
$this->assertInstanceOf(HttpRouteLocatorPluginInterface::class, $this->plugin); | ||
} | ||
|
||
|
@@ -44,11 +46,10 @@ public function testGetLocatorType() | |
public function testCreateLocator() | ||
{ | ||
$this->container | ||
->expects($this->once()) | ||
->method('get') | ||
->with(KernelInterface::class) | ||
->willReturn( | ||
$this->createMock(KernelInterface::class) | ||
$this->createMock(KernelInterface::class), | ||
$this->createMock(HttpFacadeInterface::class) | ||
); | ||
|
||
$this->assertInstanceOf(RouteLocatorInterface::class, $this->plugin->createLocator()); | ||
|
@@ -62,7 +63,7 @@ public function testProvideDependencies() | |
public function testGetDependedPlugins() | ||
{ | ||
$this->assertEquals( | ||
[ HttpCorePlugin::class ], | ||
[HttpCorePlugin::class], | ||
$this->plugin->getDependedPlugins() | ||
); | ||
} | ||
|
Oops, something went wrong.