Skip to content

Use platform specific EOL constant for log tests - #25

Closed
HLeithner wants to merge 1 commit into
clue:mainfrom
HLeithner:fix/logtest
Closed

Use platform specific EOL constant for log tests#25
HLeithner wants to merge 1 commit into
clue:mainfrom
HLeithner:fix/logtest

Conversation

@HLeithner

Copy link
Copy Markdown
Contributor

The following tests are failing if you run phpunit on windows

  1. FrameworkX\Tests\AppTest::testLogRequestResponsePrintsRequestLogWithCurrentDateAndTime
    Failed asserting that '2021-07-02 11:29:09.446 127.0.0.1 "GET /users HTTP/1.1" 200 6\r\n
    ' matches PCRE pattern "/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{3} 127.0.0.1 "GET /users HTTP/1.1" 200 6
    $/".

  2. FrameworkX\Tests\AppTest::testLogRequestResponseWithoutRemoteAddressPrintsRequestLogWithDashAsPlaceholder
    Failed asserting that '2021-07-02 11:29:09.447 - "GET /users HTTP/1.1" 200 6\r\n
    ' matches PCRE pattern "/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{3} - "GET /users HTTP/1.1" 200 6
    $/".

  3. FrameworkX\Tests\AppTest::testLogPrintsMessageWithCurrentDateAndTime
    Failed asserting that '2021-07-02 11:29:09.448 Hello\r\n
    ' matches PCRE pattern "/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{3} Hello
    $/".

The reason for this is that PHP_EOL uses "\r\n" on windows and not "\n" as expected by the test.

I'm not sure if logging output should have system specific line endings. As alternativ PHP_EOL can be replaced by "\n" in App:log()

@clue clue added bug Something isn't working maintenance labels Jul 2, 2021

@clue clue left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HLeithner Thanks for looking into this, changes LGTM!

Unfortunately this isn't currently covered by our test setup, because it currently only executes on Ubuntu. I've briefly discussed this with @SimonFrings off-channel, is this something you can look into? 👍

@HLeithner

Copy link
Copy Markdown
Contributor Author

On of my development machines is windows, that's the reason I found this.

Sadly (not really) I don't have any windows server or test other code on windows server so I don't have any experience run automated tests on windows.

I can only run them when I do it manually...

@SimonFrings

Copy link
Copy Markdown
Contributor

I'll look into this one, thanks for the work so far 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants