public function RequestMatcherTest::testAttributes

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/RequestMatcherTest.php, line 162

Class

RequestMatcherTest

Namespace

Symfony\Component\HttpFoundation\Tests

Code

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));
}