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

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

Open
CyberiaResurrection opened this issue Aug 31, 2018 · 0 comments

Comments

@CyberiaResurrection
Copy link

CyberiaResurrection commented Aug 31, 2018

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.

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