Ngiler SH3LL 360
Home
Information
Create File
Create Folder
:
/
home
/
tbf
/
conferinta_tbf
/
vendor
/
symfony
/
http-foundation
/
Tests
/
Information Server
MySQL :
OFF
Perl :
OFF
CURL :
ON
WGET :
OFF
PKEXEC :
OFF
Directive
Local Value
IP Address
89.40.16.97
System
Linux server.atelieruldeit.ro 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64
User
tbf
PHP Version
7.3.33
Software
Apache
Doc root
Writable
close
Edit File :
RequestMatcherTest.php
| Size :
5.04
KB
Copy
<?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\Component\HttpFoundation\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestMatcher; class RequestMatcherTest extends TestCase { /** * @dataProvider getMethodData */ public function testMethod($requestMethod, $matcherMethod, $isMatch) { $matcher = new RequestMatcher(); $matcher->matchMethod($matcherMethod); $request = Request::create('', $requestMethod); $this->assertSame($isMatch, $matcher->matches($request)); $matcher = new RequestMatcher(null, null, $matcherMethod); $request = Request::create('', $requestMethod); $this->assertSame($isMatch, $matcher->matches($request)); } public function getMethodData() { return [ ['get', 'get', true], ['get', ['get', 'post'], true], ['get', 'post', false], ['get', 'GET', true], ['get', ['GET', 'POST'], true], ['get', 'POST', false], ]; } public function testScheme() { $httpRequest = $request = $request = Request::create(''); $httpsRequest = $request = $request = Request::create('', 'get', [], [], [], ['HTTPS' => 'on']); $matcher = new RequestMatcher(); $matcher->matchScheme('https'); $this->assertFalse($matcher->matches($httpRequest)); $this->assertTrue($matcher->matches($httpsRequest)); $matcher->matchScheme('http'); $this->assertFalse($matcher->matches($httpsRequest)); $this->assertTrue($matcher->matches($httpRequest)); $matcher = new RequestMatcher(); $this->assertTrue($matcher->matches($httpsRequest)); $this->assertTrue($matcher->matches($httpRequest)); } /** * @dataProvider getHostData */ public function testHost($pattern, $isMatch) { $matcher = new RequestMatcher(); $request = Request::create('', 'get', [], [], [], ['HTTP_HOST' => 'foo.example.com']); $matcher->matchHost($pattern); $this->assertSame($isMatch, $matcher->matches($request)); $matcher = new RequestMatcher(null, $pattern); $this->assertSame($isMatch, $matcher->matches($request)); } public function testPort() { $matcher = new RequestMatcher(); $request = Request::create('', 'get', [], [], [], ['HTTP_HOST' => null, 'SERVER_PORT' => 8000]); $matcher->matchPort(8000); $this->assertTrue($matcher->matches($request)); $matcher->matchPort(9000); $this->assertFalse($matcher->matches($request)); $matcher = new RequestMatcher(null, null, null, null, [], null, 8000); $this->assertTrue($matcher->matches($request)); } public function getHostData() { return [ ['.*\.example\.com', true], ['\.example\.com$', true], ['^.*\.example\.com$', true], ['.*\.sensio\.com', false], ['.*\.example\.COM', true], ['\.example\.COM$', true], ['^.*\.example\.COM$', true], ['.*\.sensio\.COM', false], ]; } public function testPath() { $matcher = new RequestMatcher(); $request = Request::create('/admin/foo'); $matcher->matchPath('/admin/.*'); $this->assertTrue($matcher->matches($request)); $matcher->matchPath('/admin'); $this->assertTrue($matcher->matches($request)); $matcher->matchPath('^/admin/.*$'); $this->assertTrue($matcher->matches($request)); $matcher->matchMethod('/blog/.*'); $this->assertFalse($matcher->matches($request)); } public function testPathWithLocaleIsNotSupported() { $matcher = new RequestMatcher(); $request = Request::create('/en/login'); $request->setLocale('en'); $matcher->matchPath('^/{_locale}/login$'); $this->assertFalse($matcher->matches($request)); } public function testPathWithEncodedCharacters() { $matcher = new RequestMatcher(); $request = Request::create('/admin/fo%20o'); $matcher->matchPath('^/admin/fo o*$'); $this->assertTrue($matcher->matches($request)); } public function testAttributes() { $matcher = new RequestMatcher(); $request = Request::create('/admin/foo'); $request->attributes->set('foo', 'foo_bar'); $matcher->matchAttribute('foo', 'foo_.*'); $this->assertTrue($matcher->matches($request)); $matcher->matchAttribute('foo', 'foo'); $this->assertTrue($matcher->matches($request)); $matcher->matchAttribute('foo', '^foo_bar$'); $this->assertTrue($matcher->matches($request)); $matcher->matchAttribute('foo', 'babar'); $this->assertFalse($matcher->matches($request)); } }
Back