PathRequestMatcher example

use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestMatcher\PathRequestMatcher;

class PathRequestMatcherTest extends TestCase
{
    /** * @dataProvider getData */
    public function test(string $regexp, bool $expected)
    {
        $matcher = new PathRequestMatcher($regexp);
        $request = Request::create('/admin/foo');
        $this->assertSame($expected$matcher->matches($request));
    }

    public static function getData()
    {
        return [
            ['/admin/.*', true],
            ['/admin', true],
            ['^/admin/.*$', true],
            ['/blog/.*', false],
        ];
$this->assertEquals(
            new IteratorArgument([new Reference($expressionId)]),
            $container->getDefinition('security.cache_warmer.expression')->getArgument(0)
        );
    }

    public function testRegisterAccessControlWithSpecifiedRequestMatcherService()
    {
        $container = $this->getRawContainer();

        $requestMatcherId = 'My\Test\RequestMatcher';
        $requestMatcher = new PathRequestMatcher('/');
        $container->set($requestMatcherId$requestMatcher);

        $container->loadFromExtension('security', [
            'providers' => [
                'default' => ['id' => 'foo'],
            ],
            'firewalls' => [
                'some_firewall' => [
                    'pattern' => '/.*',
                    'http_basic' => [],
                ],
            ],
Home | Imprint | This part of the site doesn't use cookies.