Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feature #24894 [FrameworkBundle] add a notice when passing a routerIn…
…terface without warmupInterface in RouterCacheWarmer (Simperfit) This PR was merged into the 4.1-dev branch. Discussion ---------- [FrameworkBundle] add a notice when passing a routerInterface without warmupInterface in RouterCacheWarmer | Q | A | ------------- | --- | Branch? | master | Bug fix? | yesish | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #23403 | License | MIT | Doc PR | none I'm adding a test to RouterCacheWarmer since there were none. Commits ------- daa7f02 [FrameworkBundle] add a notice when passing a routerInterface with warmupInterface in RouterCacheWarmer
- Loading branch information
Showing
5 changed files
with
73 additions
and
3 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
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
56 changes: 56 additions & 0 deletions
56
src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/RouterCacheWarmerTest.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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\FrameworkBundle\Tests\CacheWarmer; | ||
|
||
use Psr\Container\ContainerInterface; | ||
use Symfony\Bundle\FrameworkBundle\CacheWarmer\RouterCacheWarmer; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface; | ||
use Symfony\Component\Routing\RouterInterface; | ||
|
||
class RouterCacheWarmerTest extends TestCase | ||
{ | ||
public function testWarmUpWithWarmebleInterface() | ||
{ | ||
$containerMock = $this->getMockBuilder(ContainerInterface::class)->setMethods(array('get', 'has'))->getMock(); | ||
|
||
$routerMock = $this->getMockBuilder(testRouterInterfaceWithWarmebleInterface::class)->setMethods(array('match', 'generate', 'getContext', 'setContext', 'getRouteCollection', 'warmUp'))->getMock(); | ||
$containerMock->expects($this->any())->method('get')->with('router')->willReturn($routerMock); | ||
$routerCacheWarmer = new RouterCacheWarmer($containerMock); | ||
|
||
$routerCacheWarmer->warmUp('/tmp'); | ||
$routerMock->expects($this->any())->method('warmUp')->with('/tmp')->willReturn(''); | ||
$this->addToAssertionCount(1); | ||
} | ||
|
||
/** | ||
* @expectedDeprecation Passing a Symfony\Component\Routing\RouterInterface without implementing Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface is deprecated since Symfony 4.1. | ||
* @group legacy | ||
*/ | ||
public function testWarmUpWithoutWarmebleInterface() | ||
{ | ||
$containerMock = $this->getMockBuilder(ContainerInterface::class)->setMethods(array('get', 'has'))->getMock(); | ||
|
||
$routerMock = $this->getMockBuilder(testRouterInterfaceWithoutWarmebleInterface::class)->setMethods(array('match', 'generate', 'getContext', 'setContext', 'getRouteCollection'))->getMock(); | ||
$containerMock->expects($this->any())->method('get')->with('router')->willReturn($routerMock); | ||
$routerCacheWarmer = new RouterCacheWarmer($containerMock); | ||
$routerCacheWarmer->warmUp('/tmp'); | ||
} | ||
} | ||
|
||
interface testRouterInterfaceWithWarmebleInterface extends RouterInterface, WarmableInterface | ||
{ | ||
} | ||
|
||
interface testRouterInterfaceWithoutWarmebleInterface extends RouterInterface | ||
{ | ||
} |