Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http-mock fails for the path '/' with the newest symfony routers (3.4.8 || 4.0.8) #45

Open
sunspikes opened this issue Apr 12, 2018 · 0 comments

Comments

@sunspikes
Copy link

This new change in symfony router (symfony/symfony#26792), now adds an extra check to make sure there are allowed methods configured in case the matching path is '/'.

I am not 100% sure if this is a side effect of a bit hacky approach to rely on app errors (without registering any proper routes) or a possible BC break by the symfony router.

Example test case:

<?php

namespace Tests;

use InterNations\Component\HttpMock\PHPUnit\HttpMockTrait;
use PHPUnit\Framework\TestCase;

class ExampleTest extends TestCase
{
    use HttpMockTrait;

    public static function setUpBeforeClass()
    {
        static::setUpHttpMockBeforeClass('8082', 'localhost');
    }

    public static function tearDownAfterClass()
    {
        static::tearDownHttpMockAfterClass();
    }

    public function setUp()
    {
        $this->setUpHttpMock();
    }

    public function tearDown()
    {
        $this->tearDownHttpMock();
    }

    public function testSimpleRequest()
    {
        $this->http->mock
            ->when()
            ->methodIs('GET')
            ->pathIs('/')
            ->then()
            ->body('mocked body')
            ->end();
        $this->http->setUp();

        $this->assertSame('mocked body', file_get_contents('http://localhost:8082/'));
    }
}

This test will fail because now router will throw a NoConfigurationException

@sunspikes sunspikes changed the title http-mock fails for the path '/' with the newest symfony router (3.4.8) http-mock fails for the path '/' with the newest symfony routerx (3.4.8) Apr 12, 2018
@sunspikes sunspikes changed the title http-mock fails for the path '/' with the newest symfony routerx (3.4.8) http-mock fails for the path '/' with the newest symfony routers (3.4.8 || 4.0.8) Apr 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant