* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\ExpressionLanguage\ExpressionLanguage; use Symfony\Component\HttpFoundation\ExpressionRequestMatcher; use Symfony\Component\HttpFoundation\Request; class ExpressionRequestMatcherTest extends TestCase { /** * @expectedException \LogicException */ public function testWhenNoExpressionIsSet() { $expressionRequestMatcher = new ExpressionRequestMatcher(); $expressionRequestMatcher->matches(new Request()); } /** * @dataProvider provideExpressions */ public function testMatchesWhenParentMatchesIsTrue($expression, $expected) { $request = Request::create('/foo'); $expressionRequestMatcher = new ExpressionRequestMatcher(); $expressionRequestMatcher->setExpression(new ExpressionLanguage(), $expression); $this->assertSame($expected, $expressionRequestMatcher->matches($request)); } /** * @dataProvider provideExpressions */ public function testMatchesWhenParentMatchesIsFalse($expression) { $request = Request::create('/foo'); $request->attributes->set('foo', 'foo'); $expressionRequestMatcher = new ExpressionRequestMatcher(); $expressionRequestMatcher->matchAttribute('foo', 'bar'); $expressionRequestMatcher->setExpression(new ExpressionLanguage(), $expression); $this->assertFalse($expressionRequestMatcher->matches($request)); } public function provideExpressions() { return array( array('request.getMethod() == method', true), array('request.getPathInfo() == path', true), array('request.getHost() == host', true), array('request.getClientIp() == ip', true), array('request.attributes.all() == attributes', true), array('request.getMethod() == method && request.getPathInfo() == path && request.getHost() == host && request.getClientIp() == ip && request.attributes.all() == attributes', true), array('request.getMethod() != method', false), array('request.getMethod() != method && request.getPathInfo() == path && request.getHost() == host && request.getClientIp() == ip && request.attributes.all() == attributes', false), ); } } __halt_compiler();----SIGNATURE:----QMKvh1f6kMFm7Kv2pl1HNU1Bz1gfxKUVgU5t09uNGIhf+aLBSpeajubXWZ8gGtqKJz5oxIwCx3yF0uueNpvbJ/Cce0kOZikNUaW3HIPmZMZaCgMwyADSjsCLi///ZCIJJqebKAfzrYGLqbHKhhFoo894vbXIFaVJjFsdL7SjTG9sP+MXNXWHrSzb7s4BKUB/3kXflbD8ZyQlc4tvAG7O2QWSYFp77KK9D9K6ZDrnRAbmJTESHf6uNFLxupEmTiIJ1Me/2nlUolKzuQuwt977tcuMogW7XwfDJJzFOGxGTnTK7QAqhw3yawnBA+qBxGEF2W/GDHmRhiWcP/GGuC2dqkDdSymE0Vp9R98KVbDfWIGAb5KeSuI/7COnwW00jKo1uOptXs9lAsWHhxglHrrZbh2qko7m6d23vuwtP7re0BJYDQWVUZxk8geX7Gok8euSHp85fmaKMizL2NHCstvrtExni1FYlQSicR35IInI+FIMQvjFuRrNrQyVGEVDvatlK8Vlm73/WgZwSa9wCiaQ8cXh+RryodG1VUwlN2bheHH3um61nGQMRtB0q/TNqdPmG4l7OOvfcOhQixJ3pjeLAIedKSRj8W3A+7ZLX2p3x4Knd+JMidbRzNP38QV74OXLKeQrhK75zsMs7l7FTVNAkLli4c9HWGwr0jP1AsepHSM=----ATTACHMENT:----MTk5MzA0OTUwODY4ODkzMyAxMzAwMjQzNTcxNTQ3OTcyIDQ1MzY3MDg4MTU3MzUwNzc=