Skip to content

Commit

Permalink
Merge pull request #402 from FriendsOfSymfony/prepare-2.2-alpha
Browse files Browse the repository at this point in the history
cleanup before 2.2 alpha release
  • Loading branch information
dbu committed Nov 9, 2017
2 parents 2278528 + 0a79a26 commit 97eaf18
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 11 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ Changelog
`"strong"` or `"weak"` respectively.
Value `true` due to backward compatibility will be resolved as `"strong"`.

### Fixed

* The FlashMessageListener has been broken during refactoring for 2.0 and now
works again. Constructor uses an options array.

* Tag annotations now work with SensioFrameworkExtraBundle 4. An accidental
exception prevents using them with FOSHttpCacheBundle 2.0 and 2.1.

* User context is more reliable not cache when the hash mismatches. (E.g. after
login/logout.)

2.1.0
-----

Expand Down
5 changes: 3 additions & 2 deletions src/Configuration/InvalidateRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationAnnotation;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;

/**
* @Annotation
Expand Down Expand Up @@ -67,13 +68,13 @@ public function setParams($params)
if (is_array($value)) {
if (1 !== count($value) || !isset($value['expression'])) {
throw new \RuntimeException(sprintf(
'@InvalidateRoute param %s must be string or {"expression"="<expression>"}',
'@InvalidateRoute param %s must be string or {"expression"="<expression>"}, %s given',
$name,
print_r($value, true)
));
}
// @codeCoverageIgnoreStart
if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) {
if (!class_exists(ExpressionLanguage::class)) {
throw new InvalidConfigurationException(sprintf(
'@InvalidateRoute param %s uses an expression but the ExpressionLanguage is not available.',
$name
Expand Down
5 changes: 3 additions & 2 deletions src/Configuration/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use FOS\HttpCacheBundle\Exception\InvalidTagException;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationAnnotation;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;

/**
* @Annotation
Expand All @@ -39,8 +40,8 @@ public function setValue($data)
public function setExpression($expression)
{
// @codeCoverageIgnoreStart
if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) {
throw new InvalidConfigurationException('@Tag param %s uses an expression but the ExpressionLanguage is not available.');
if (!class_exists(ExpressionLanguage::class)) {
throw new InvalidConfigurationException('@Tag param uses an expression but the ExpressionLanguage is not available.');
}
// @codeCoverageIgnoreEnd
$this->expression = $expression;
Expand Down
3 changes: 2 additions & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

/**
Expand Down Expand Up @@ -529,7 +530,7 @@ private function addTagSection(ArrayNodeDefinition $rootNode)
->fixXmlConfig('tag_expression')
->validate()
->ifTrue(function ($v) {
return !empty($v['tag_expressions']) && !class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage');
return !empty($v['tag_expressions']) && !class_exists(ExpressionLanguage::class);
})
->thenInvalid('Configured a tag_expression but ExpressionLanugage is not available')
->end()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ContextInvalidationLogoutHandler implements LogoutHandlerInterface
/**
* Service used to ban hash request.
*
* @var \FOS\HttpCache\ProxyClient\Invalidation\BanCapable
* @var BanCapable
*/
private $banner;

Expand Down
3 changes: 2 additions & 1 deletion tests/Functional/EventListener/FlashMessageListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace FOS\HttpCacheBundle\Tests\Functional\EventListener;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\HttpFoundation\Cookie;

class FlashMessageListenerTest extends WebTestCase
{
Expand All @@ -27,7 +28,7 @@ public function testFlashMessageCookieIsSet()
$cookies = $response->headers->getCookies();
$this->assertCount(2, $cookies);

/** @var \Symfony\Component\HttpFoundation\Cookie $cookie */
/** @var Cookie $cookie */
$cookie = $cookies[0];

$this->assertEquals('/', $cookie->getPath());
Expand Down
3 changes: 2 additions & 1 deletion tests/Functional/Fixtures/app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* file that was distributed with this source code.
*/

use Symfony\Component\Asset\Package;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage;
Expand Down Expand Up @@ -38,7 +39,7 @@ public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__.'/config/config.yml');

if (class_exists('Symfony\Component\Asset\Package')) {
if (class_exists(Package::class)) {
$loader->load(function (ContainerBuilder $container) {
$container->loadFromExtension('framework', ['assets' => []]);
});
Expand Down
6 changes: 4 additions & 2 deletions tests/Unit/EventListener/CacheControlListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;

class CacheControlListenerTest extends \PHPUnit_Framework_TestCase
{
Expand Down Expand Up @@ -389,6 +390,7 @@ public function testMatchRule()
*/
public function testUnsafeMethod()
{
/** @var CacheControlListener|\PHPUnit_Framework_MockObject_MockObject $listener */
$listener = $this->getMockBuilder(CacheControlListener::class)
->setMethods(['matchRule'])
->getMock()
Expand All @@ -411,8 +413,8 @@ public function testUnsafeMethod()
*/
protected function buildEvent($method = 'GET')
{
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')
->getMock();
/** @var HttpKernelInterface|\PHPUnit_Framework_MockObject_MockObject $kernel */
$kernel = $this->createMock(HttpKernelInterface::class);
$response = new Response();
$request = new Request();
$request->setMethod($method);
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/UserContext/RoleProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use FOS\HttpCache\UserContext\UserContext;
use FOS\HttpCacheBundle\UserContext\RoleProvider;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Role\Role;

class RoleProviderTest extends \PHPUnit_Framework_TestCase
Expand All @@ -22,7 +23,7 @@ public function testProvider()
{
$roles = [new Role('ROLE_USER')];

$token = \Mockery::mock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
$token = \Mockery::mock(TokenInterface::class);

$securityContext = $this->getTokenStorageMock();
$securityContext->shouldReceive('getToken')->andReturn($token);
Expand Down

0 comments on commit 97eaf18

Please sign in to comment.