Skip to content

Commit

Permalink
Tests_Import_Parser::test_blank_lines_in_content(): minor test fix
Browse files Browse the repository at this point in the history
Depending on how a git repo is cloned, files may have *nix line endings or Windows line endings.
Now, as this test uses a file based fixture, this has an impact on the tests.

As things are, the test basically assumes that `core.autocrlf=true` (change line endings based on the OS) is used, while that is an assumption which cannot be made.

This can lead to confusion for contributors when they are confronted by an inexplicably failing test.

As the Windows line ending `\r\n` includes the *nix line ending `\n` anyway, changing the test to just check for the count of the `\n` characters maintains the value of the test, while preventing test failures for contributors who run the test on Windows and check out with `core.autocrlf=input`.
  • Loading branch information
jrfnl committed Sep 13, 2024
1 parent 08aa7f4 commit f247994
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion phpunit/tests/parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ function test_blank_lines_in_content() {
$result = $parser->parse( $file );

// Check the number of new lines characters
$this->assertSame( 3, substr_count( $result['posts'][0]['post_content'], PHP_EOL ), $message );
$this->assertSame( 3, substr_count( $result['posts'][0]['post_content'], "\n" ), $message );
}
}

Expand Down

0 comments on commit f247994

Please sign in to comment.