* * 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:----wf5/1aYNvNiXqsvgrMdkc2DpnSoiKfvC5U2lh/4WVySyE397o9IEMTjY3YyoBfEeiQXg3oagGue+skQUlzWjxEZQQttYm3Og0wHTZdhitRQW0DPQi5z4Iv7e5LuN7nu9W7cd+cFnAbauBIb0WGxCLrar3XAcrLtHpEx4BgLbSHk2j+0FsNaRfVd1Qpyw2lEHSqFdwTQeQZv561LB0ogO6RjEnV2s/cGMFmzxjRC2693XYVA5iTtQBvWk8bW+iyc+RL52/K9DUTI75MOeNumzaBbfcydv/MiuIHJoc4rNHqv7gISidA8DCXb208tZOfRPqgcrnxNEMpPoSwtA2XcPHYCqDCQdY/Cc66/7v+UZYx1Te02EfYMUu5jWN21g041ZxRt+x7esF/GY2ognoFceICfd+CGjj5DIdZKjfzagTJjKsI9MpDt57GeVhAZc/77fWqRpQZ1QEHJFB3Nmfywti04vv8ZSgg/tZgSOhqnjNCEeIuTy+0nrXRzKLrkx2+6alvQGL3ObYZ3/KaEvmdpskh+hAgyl7g9eEV8ELofQwIdmEgNs+Cg5fku52hXEwKiI9rurNpXUUizgjc3HbSJ/rP46h+ZfbNaxdmL35T4MoIvu3+aKL3p7MnxmkJxOy17wrRlsF6F+GKbKlmcaoDKGx8dQ5oYAmlz3lEBhDuoRMLI=----ATTACHMENT:----NDAxNTAyNzYwODMwOTk2NiA5ODg5ODI0Nzg5OTMzOTYgOTcwMDk1NzEwMzczNzk4Mg==