assertRequestAttributeValueSame example

public function testAssertNoFormValue()
    {
        $this->getCrawlerTester(new Crawler('<html><body><form id="form"><input type="checkbox" name="rememberMe">', 'http://localhost'))->assertNoFormValue('#form', 'rememberMe');
        $this->expectException(AssertionFailedError::class);
        $this->expectExceptionMessage('Field "rememberMe" has a value in form "#form".');
        $this->getCrawlerTester(new Crawler('<html><body><form id="form"><input type="checkbox" name="rememberMe" checked>', 'http://localhost'))->assertNoFormValue('#form', 'rememberMe');
    }

    public function testAssertRequestAttributeValueSame()
    {
        $this->getRequestTester()->assertRequestAttributeValueSame('foo', 'bar');
        $this->expectException(AssertionFailedError::class);
        $this->expectExceptionMessage('Failed asserting that the Request has attribute "foo" with value "baz".');
        $this->getRequestTester()->assertRequestAttributeValueSame('foo', 'baz');
    }

    public function testAssertRouteSame()
    {
        $this->getRequestTester()->assertRouteSame('homepage', ['foo' => 'bar']);
        $this->expectException(AssertionFailedError::class);
        $this->expectExceptionMessage('Failed asserting that the Request has attribute "_route" with value "articles".');
        $this->getRequestTester()->assertRouteSame('articles');
    }
Home | Imprint | This part of the site doesn't use cookies.