Skip to content

Problems running built-in server under PHP 7.1.21 on Fedora 27 #48

@CyberiaResurrection

Description

@CyberiaResurrection

I'm setting up a mock under the above PHP version, using PHPUnit 6.5.21, and have run into problems simply trying to get an empty test to run. I haven't hooked up any specific framework, beyond the bits that http-mock itself pulls in.

Here's the guts of my base test class:

<?php
namespace Tests;

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

abstract class TestCase extends BaseTestCase

    use HttpMockTrait;	
    public static function setUpBeforeClass()
    {
        static::setUpHttpMockBeforeClass(null, 'localhost');
    }

    public static function tearDownAfterClass()
    {
        static::tearDownHttpMockAfterClass();
    }
    public function setUp()
    {
        $this->setUpHttpMock();
        parent::setUp();
        $this->http->mock
            ->when()
                ->methodIs('POST')
            ->then()
                ->body('')
            ->end();
        $this->http->setUp();
    }
    public function tearDown()
    {
        $this->tearDownHttpMock();
        parent::tearDown();
    }
}

And the test in question

class baseTest extends TestCase {
    public function testSimpleRequest()
    {
        $request = $this->http->requests->latest();
    }
}

Test result:

1) ...\Tests\baseTest::testSimpleRequest
UnexpectedValueException: Expected status code 200 from "/_request/last", got 404

.../vendor/internations/http-mock/src/RequestCollectionFacade.php:158
.../vendor/internations/http-mock/src/RequestCollectionFacade.php:141
.../vendor/internations/http-mock/src/RequestCollectionFacade.php:27
.../tests/baseTest.php:18

I'm not sure what else I can trim out. Have I managed to do something dumb like leave out a "start the mock server" step? From a quick read through the getting started guide, it doesn't seem like that.

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