tchwork / utf8

Portable and performant UTF-8, Unicode and Grapheme Clusters for PHP
Apache License 2.0
627 stars 50 forks source link

Tests fail with PHP 7.1 (because support added for negative string offsets) #61

Closed siwinski closed 3 years ago

siwinski commented 7 years ago

PHP 7.1 new feature: Support for negative string offsets: http://php.net/manual/en/migration71.new-features.php#migration71.new-features.support-for-negative-string-offsets

PHPUnit

PHPUnit 5.7.3 by Sebastian Bergmann and contributors.
Runtime:       PHP 7.1.0
Configuration: /builddir/build/BUILD/utf8-30ec6451aec7d2536f0af8fe535f70c764f2c47a/phpunit.xml.dist
......................F........................................  63 / 247 ( 25%)
............................................................... 126 / 247 ( 51%)
............................................................... 189 / 247 ( 76%)
.......................SSSSSSSSS..........................      247 / 247 (100%)
Time: 147 ms, Memory: 14.06MB
There was 1 failure:
1) Patchwork\Tests\PHP\Shim\MbstringTest::testmb_strpos_negative_offset
Failed asserting that exception of type "PHPUnit_Framework_ExpectationFailedException" matches expected exception "PHPUnit_Framework_Error_Warning". Message was: "The previous line should trigger a warning (Offset not contained in string)
Failed asserting that true is false." at
/builddir/build/BUILD/utf8-30ec6451aec7d2536f0af8fe535f70c764f2c47a/tests/PHP/Shim/MbstringTest.php:163
.
--
There were 9 skipped tests:
1) Patchwork\Tests\Utf8\WindowsStreamWrapperTest::testRelDir
Extension com_dotnet is required.
/builddir/build/BUILD/utf8-30ec6451aec7d2536f0af8fe535f70c764f2c47a/tests/Utf8/WindowsStreamWrapperTest.php:46
2) Patchwork\Tests\Utf8\WindowsStreamWrapperTest::testDir
Extension com_dotnet is required.
/builddir/build/BUILD/utf8-30ec6451aec7d2536f0af8fe535f70c764f2c47a/tests/Utf8/WindowsStreamWrapperTest.php:46
3) Patchwork\Tests\Utf8\WindowsStreamWrapperTest::testFileOp
Extension com_dotnet is required.
/builddir/build/BUILD/utf8-30ec6451aec7d2536f0af8fe535f70c764f2c47a/tests/Utf8/WindowsStreamWrapperTest.php:46
4) Patchwork\Tests\Utf8\WindowsStreamWrapperTest::testFilePutGetContents
Extension com_dotnet is required.
/builddir/build/BUILD/utf8-30ec6451aec7d2536f0af8fe535f70c764f2c47a/tests/Utf8/WindowsStreamWrapperTest.php:46
5) Patchwork\Tests\Utf8\WindowsStreamWrapperTest::testFopenX
Extension com_dotnet is required.
/builddir/build/BUILD/utf8-30ec6451aec7d2536f0af8fe535f70c764f2c47a/tests/Utf8/WindowsStreamWrapperTest.php:46
6) Patchwork\Tests\Utf8\WindowsStreamWrapperTest::testMkdir
Extension com_dotnet is required.
/builddir/build/BUILD/utf8-30ec6451aec7d2536f0af8fe535f70c764f2c47a/tests/Utf8/WindowsStreamWrapperTest.php:46
7) Patchwork\Tests\Utf8\WindowsStreamWrapperTest::testMkdirRecursive
Extension com_dotnet is required.
/builddir/build/BUILD/utf8-30ec6451aec7d2536f0af8fe535f70c764f2c47a/tests/Utf8/WindowsStreamWrapperTest.php:46
8) Patchwork\Tests\Utf8\WindowsStreamWrapperTest::testStat
Extension com_dotnet is required.
/builddir/build/BUILD/utf8-30ec6451aec7d2536f0af8fe535f70c764f2c47a/tests/Utf8/WindowsStreamWrapperTest.php:46
9) Patchwork\Tests\Utf8\WindowsStreamWrapperTest::testStreamtMetadata
Extension com_dotnet is required.
/builddir/build/BUILD/utf8-30ec6451aec7d2536f0af8fe535f70c764f2c47a/tests/Utf8/WindowsStreamWrapperTest.php:46
FAILURES!
Tests: 247, Assertions: 598, Failures: 1, Skipped: 9.

Minimal recreation of issue with PHP 5.6, 7.0, and 7.1:

$ php --version
PHP 5.6.28 (cli) (built: Nov  9 2016 07:56:20) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

$ php -r "mb_strpos('abc', 'a', -1);"
PHP Warning:  mb_strpos(): Offset not contained in string in Command line code on line 1

Warning: mb_strpos(): Offset not contained in string in Command line code on line 1
$ php70 --version
PHP 7.0.14 (cli) (built: Dec  7 2016 08:52:01) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies

$ php70 -r "mb_strpos('abc', 'a', -1);"
PHP Warning:  mb_strpos(): Offset not contained in string in Command line code on line 1
$ php71 --version
PHP 7.1.0 (cli) (built: Dec  1 2016 06:32:55) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.1.0-dev, Copyright (c) 1998-2016 Zend Technologies

$ php71 -r "mb_strpos('abc', 'a', -1);"