8000 http-mock fails for the path '/' with the newest symfony routers (3.4.8 || 4.0.8) · Issue #45 · InterNations/http-mock · GitHub
[go: up one dir, main page]

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

Description

@sunspikes

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

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