8000 Domain required in Phpunit test when redirecting · Issue #21189 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Domain required in Phpunit test when redirecting #21189
Closed
@c33s

Description

@c33s
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.2.1
  • PHPUnit 5.7.4
  • PHP 7.0.13
  • Windows7x64
  • Symfony 3.2.1

the following test, taken from https://symfony.com/doc/current/testing.html#working-with-the-test-client (scroll up to Useful Assertions), shows the example without domain:

// Assert that the response is a redirect to /demo/contact
$this->assertTrue(
    $client->getResponse()->isRedirect('/demo/contact'),
    'response is a redirect to /demo/contact'
);

doing the same in my tests fails:

    public function testPressRedirect()
    {
        $client = static::createClient();
        $client->request('GET', '/press');
        $this->assertTrue($client->getResponse()->isRedirect('/en/press')); //fails
    }

routing.yml

_press_redirect:
    path: /press
    defaults:
        _controller: FrameworkBundle:Redirect:urlRedirect
        path: /en/press
        permanent: true

I have to include the domain and the protocol to make it work:

    public function testPressRedirect()
    {
        $client = static::createClient();
        $client->request('GET', '/press');
        $this->assertTrue($client->getResponse()->isRedirect('http://localhost/en/press')); //works
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0