我在CakePHP中遇到过几个我想提交修复的问题,但我想确保我所做的任何更改都通过了单元测试。问题是单元测试对于我来说非常适合使用开箱即用的代码!我确信单位测试本身很好并且通过其他人很好,所以它可能在我的环境中引起了问题。
我在PHP 5.6.19版上运行CakePHP版本3.2.5。我的PHP构建配置(包括因为我不得不重建它几次以使它运行这么多的测试,所以理论上这可能是这个问题):
'./configure' '--enable-fileinfo' '--enable-phar' '--disable-maintainer-zts' '--enable-bcmath' '--enable-calendar' '--enable-ftp' '--enable-gd-native-ttf' '--enable-libxml' '--enable-mbstring' '--enable-pdo=shared' '--enable-sockets' '--with-apxs2=/usr/sbin/apxs' '--with-curl' '--with-freetype-dir=/usr' '--with-gd' '--with-jpeg-dir=/usr' '--with-kerberos' '--with-libdir=lib64' '--with-mssql=/usr' '--with-mysql=/usr' '--with-mysqli=/usr/bin/mysql_config' '--with-pcre-regex' '--with-pdo-mysql=shared' '--without-sqlite' '--with-sqlite3=shared' '--with-pdo-sqlite=shared,/usr' '--with-pic' '--with-png-dir=/usr' '--with-zlib' '--with-zlib-dir=/usr' '--with-openssl' '--enable-intl'
可能还有php.ini设置会影响其中一些吗?
$ git clone git@github.com:cakephp/cakephp.git
$ cd cakephp
$ make test
[bunch of stuff here where it installs all the dependencies]
vendor/bin/phpunit
PHPUnit 5.2.12 by Sebastian Bergmann and contributors.
............................................................. 61 / 6777 ( 0%)
[etc.]
............................................................. 1159 / 6777 ( 17%)
........FF......PHP Fatal error: Call to a member function format() on null in /home/cake/cakephp/tests/TestCase/I18n/DateTest.php on line 170
Fatal error: Call to a member function format() on null in /home/cake/cakephp/tests/TestCase/I18n/DateTest.php on line 170
make: *** [test] Error 255
这是因为它试图解析" 13 10,2015"使用fr_FR语言环境,但似乎无效。我通过将字符串更改为" 13/10 / 2015"来修复它。在第169和185行。(我还添加了assertNotNull
个电话。)
$ make test
[etc.]
............................................................. 4209 / 6777 ( 62%)
.......................FF.......................PHP Fatal error: Call to a member function format() on null in /home/cake/cakephp/tests/TestCase/Database/Type/TimeTypeTest.php on line 184
Fatal error: Call to a member function format() on null in /home/cake/cakephp/tests/TestCase/Database/Type/TimeTypeTest.php on line 184
make: *** [test] Error 255
我没有完全跟踪这个,只是让它失败并允许测试继续添加$this->assertNotNull($result);
。
$ make test
[etc.]
There were 5 errors:
1) Cake\Test\TestCase\I18n\IcuFormatterTest::testNativePluralSelection
Aura\Intl\Exception\CannotInstantiateFormatter: msgfmt_create: message formatter creation failed: U_ILLEGAL_CHARACTER
/home/cake/cakephp/src/I18n/Formatter/IcuFormatter.php:97
/home/cake/cakephp/src/I18n/Formatter/IcuFormatter.php:51
/home/cake/cakephp/tests/TestCase/I18n/Formatter/IcuFormatterTest.php:81
2) Cake\Test\TestCase\ORM\QueryTest::testCountWithSubselect
PDOException: SQLSTATE[HY000]: General error: 25 bind or column index out of range
/home/cake/cakephp/src/Database/Statement/StatementDecorator.php:171
/home/cake/cakephp/src/Database/Statement/StatementDecorator.php:171
/home/cake/cakephp/src/Database/Statement/BufferedStatement.php:74
/home/cake/cakephp/src/Database/Statement/SqliteStatement.php:41
/home/cake/cakephp/src/Database/Connection.php:270
/home/cake/cakephp/src/Database/Query.php:188
/home/cake/cakephp/src/ORM/Query.php:793
/home/cake/cakephp/src/ORM/Query.php:739
/home/cake/cakephp/tests/TestCase/ORM/QueryTest.php:1543
/home/cake/cakephp/tests/TestCase/DatabaseSuite.php:68
3) Cake\Test\TestCase\ORM\QueryTest::testCountWithExpressions
PDOException: SQLSTATE[HY000]: General error: 25 bind or column index out of range
/home/cake/cakephp/src/Database/Statement/StatementDecorator.php:171
/home/cake/cakephp/src/Database/Statement/StatementDecorator.php:171
/home/cake/cakephp/src/Database/Statement/BufferedStatement.php:74
/home/cake/cakephp/src/Database/Statement/SqliteStatement.php:41
/home/cake/cakephp/src/Database/Connection.php:270
/home/cake/cakephp/src/Database/Query.php:188
/home/cake/cakephp/src/ORM/Query.php:793
/home/cake/cakephp/src/ORM/Query.php:739
/home/cake/cakephp/tests/TestCase/ORM/QueryTest.php:1564
/home/cake/cakephp/tests/TestCase/DatabaseSuite.php:68
4) Cake\Test\TestCase\ORM\QueryTest::testCountWithSubselect
PDOException: SQLSTATE[HY000]: General error: 25 bind or column index out of range
/home/cake/cakephp/src/Database/Statement/StatementDecorator.php:171
/home/cake/cakephp/src/Database/Statement/StatementDecorator.php:171
/home/cake/cakephp/src/Database/Statement/BufferedStatement.php:74
/home/cake/cakephp/src/Database/Statement/SqliteStatement.php:41
/home/cake/cakephp/src/Database/Connection.php:270
/home/cake/cakephp/src/Database/Query.php:188
/home/cake/cakephp/src/ORM/Query.php:793
/home/cake/cakephp/src/ORM/Query.php:739
/home/cake/cakephp/tests/TestCase/ORM/QueryTest.php:1543
/home/cake/cakephp/tests/TestCase/DatabaseSuite.php:68
5) Cake\Test\TestCase\ORM\QueryTest::testCountWithExpressions
PDOException: SQLSTATE[HY000]: General error: 25 bind or column index out of range
/home/cake/cakephp/src/Database/Statement/StatementDecorator.php:171
/home/cake/cakephp/src/Database/Statement/StatementDecorator.php:171
/home/cake/cakephp/src/Database/Statement/BufferedStatement.php:74
/home/cake/cakephp/src/Database/Statement/SqliteStatement.php:41
/home/cake/cakephp/src/Database/Connection.php:270
/home/cake/cakephp/src/Database/Query.php:188
/home/cake/cakephp/src/ORM/Query.php:793
/home/cake/cakephp/src/ORM/Query.php:739
/home/cake/cakephp/tests/TestCase/ORM/QueryTest.php:1564
/home/cake/cakephp/tests/TestCase/DatabaseSuite.php:68
--
There were 26 failures:
1) Cake\Test\TestCase\I18n\DateTest::testI18nFormat with data set "mutable" ('Cake\I18n\Date')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'jeudi 14 janvier 2010 00:00:00 UTC'
+'jeudi 14 janvier 2010 00:00:00 UTC+00:00'
/home/cake/cakephp/tests/TestCase/I18n/DateTest.php:112
2) Cake\Test\TestCase\I18n\DateTest::testI18nFormat with data set "immutable" ('Cake\I18n\FrozenDate')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'jeudi 14 janvier 2010 00:00:00 UTC'
+'jeudi 14 janvier 2010 00:00:00 UTC+00:00'
/home/cake/cakephp/tests/TestCase/I18n/DateTest.php:112
3) Cake\Test\TestCase\I18n\NumberTest::testCurrency
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'₹ 10,01,00,100.00'
+'Rs 10,01,00,100.00'
/home/cake/cakephp/tests/TestCase/I18n/NumberTest.php:206
4) Cake\Test\TestCase\I18n\NumberTest::testConfig
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'₹ 15,000.00'
+'Rs 15,000.00'
/home/cake/cakephp/tests/TestCase/I18n/NumberTest.php:550
5) Cake\Test\TestCase\I18n\NumberTest::testOrdinal
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'1st'
+'1ˢᵗ'
/home/cake/cakephp/tests/TestCase/I18n/NumberTest.php:569
6) Cake\Test\TestCase\I18n\TimeTest::testI18nFormat with data set "mutable" ('Cake\I18n\Time')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-jueves 14 de enero de 2010 13:59:28 GMT
+jueves 14 de enero de 2010 13:59:28 GMT+00:00
/home/cake/cakephp/tests/TestCase/I18n/TimeTest.php:858
/home/cake/cakephp/tests/TestCase/I18n/TimeTest.php:439
7) Cake\Test\TestCase\I18n\TimeTest::testI18nFormat with data set "immutable" ('Cake\I18n\FrozenTime')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-jueves 14 de enero de 2010 13:59:28 GMT
+jueves 14 de enero de 2010 13:59:28 GMT+00:00
/home/cake/cakephp/tests/TestCase/I18n/TimeTest.php:858
/home/cake/cakephp/tests/TestCase/I18n/TimeTest.php:439
8) Cake\Test\TestCase\I18n\TimeTest::testI18nFormatWithOffsetTimezone with data set "mutable" ('Cake\I18n\Time')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-Wednesday January 1 2014 12:00:00 AM GMT
+Wednesday January 1 2014 12:00:00 AM GMT+00:00
/home/cake/cakephp/tests/TestCase/I18n/TimeTest.php:858
/home/cake/cakephp/tests/TestCase/I18n/TimeTest.php:496
9) Cake\Test\TestCase\I18n\TimeTest::testI18nFormatWithOffsetTimezone with data set "immutable" ('Cake\I18n\FrozenTime')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-Wednesday January 1 2014 12:00:00 AM GMT
+Wednesday January 1 2014 12:00:00 AM GMT+00:00
/home/cake/cakephp/tests/TestCase/I18n/TimeTest.php:858
/home/cake/cakephp/tests/TestCase/I18n/TimeTest.php:496
10) Cake\Test\TestCase\I18n\TimeTest::testToString with data set "mutable" ('Cake\I18n\Time')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-dimanche 20 avril 2014 22:10:00 UTC
+dimanche 20 avril 2014 22:10:00 UTC+00:00
/home/cake/cakephp/tests/TestCase/I18n/TimeTest.php:858
/home/cake/cakephp/tests/TestCase/I18n/TimeTest.php:567
11) Cake\Test\TestCase\I18n\TimeTest::testToString with data set "immutable" ('Cake\I18n\FrozenTime')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-dimanche 20 avril 2014 22:10:00 UTC
+dimanche 20 avril 2014 22:10:00 UTC+00:00
/home/cake/cakephp/tests/TestCase/I18n/TimeTest.php:858
/home/cake/cakephp/tests/TestCase/I18n/TimeTest.php:567
12) Cake\Test\TestCase\I18n\TimeTest::testParseDateTime with data set "mutable" ('Cake\I18n\Time')
Failed asserting that null is not null.
/home/cake/cakephp/tests/TestCase/I18n/TimeTest.php:746
13) Cake\Test\TestCase\I18n\TimeTest::testParseDateTime with data set "immutable" ('Cake\I18n\FrozenTime')
Failed asserting that null is not null.
/home/cake/cakephp/tests/TestCase/I18n/TimeTest.php:746
14) Cake\Test\TestCase\I18n\TimeTest::testParseDate with data set "mutable" ('Cake\I18n\Time')
Failed asserting that null is not null.
/home/cake/cakephp/tests/TestCase/I18n/TimeTest.php:780
15) Cake\Test\TestCase\I18n\TimeTest::testParseDate with data set "immutable" ('Cake\I18n\FrozenTime')
Failed asserting that null is not null.
/home/cake/cakephp/tests/TestCase/I18n/TimeTest.php:780
16) Cake\Test\TestCase\I18n\TimeTest::testParseTime with data set "mutable" ('Cake\I18n\Time')
Failed asserting that null is not null.
/home/cake/cakephp/tests/TestCase/I18n/TimeTest.php:800
17) Cake\Test\TestCase\I18n\TimeTest::testParseTime with data set "immutable" ('Cake\I18n\FrozenTime')
Failed asserting that null is not null.
/home/cake/cakephp/tests/TestCase/I18n/TimeTest.php:800
18) Cake\Test\TestCase\Network\ResponseTest::testOutputCompressed
Failed asserting that true is false.
/home/cake/cakephp/tests/TestCase/Network/ResponseTest.php:532
19) Cake\Test\TestCase\Validation\ValidationTest::testLocalizedTime
Failed asserting that false is true.
/home/cake/cakephp/tests/TestCase/Validation/ValidationTest.php:1570
20) Cake\Test\TestCase\View\Helper\TimeHelperTest::testFormat
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'Thursday January 14 2010 1:59:28 PM GMT'
+'Thursday January 14 2010 1:59:28 PM GMT+00:00'
/home/cake/cakephp/tests/TestCase/View/Helper/TimeHelperTest.php:499
/home/cake/cakephp/tests/TestCase/View/Helper/TimeHelperTest.php:441
21) Cake\Test\TestCase\Database\Type\DateTimeTypeTest::testLocaleParserDisable
null does not match expected type "object".
/home/cake/cakephp/tests/TestCase/Database/Type/DateTimeTypeTest.php:227
/home/cake/cakephp/tests/TestCase/DatabaseSuite.php:68
22) Cake\Test\TestCase\Database\Type\DateTimeTypeTest::testMarshalWithLocaleParsing
null does not match expected type "object".
/home/cake/cakephp/tests/TestCase/Database/Type/DateTimeTypeTest.php:244
/home/cake/cakephp/tests/TestCase/DatabaseSuite.php:68
23) Cake\Test\TestCase\Database\Type\TimeTypeTest::testMarshalWithLocaleParsing
Failed asserting that null is not null.
/home/cake/cakephp/tests/TestCase/Database/Type/TimeTypeTest.php:184
/home/cake/cakephp/tests/TestCase/DatabaseSuite.php:68
24) Cake\Test\TestCase\Database\Type\DateTimeTypeTest::testLocaleParserDisable
null does not match expected type "object".
/home/cake/cakephp/tests/TestCase/Database/Type/DateTimeTypeTest.php:227
/home/cake/cakephp/tests/TestCase/DatabaseSuite.php:68
25) Cake\Test\TestCase\Database\Type\DateTimeTypeTest::testMarshalWithLocaleParsing
null does not match expected type "object".
/home/cake/cakephp/tests/TestCase/Database/Type/DateTimeTypeTest.php:244
/home/cake/cakephp/tests/TestCase/DatabaseSuite.php:68
26) Cake\Test\TestCase\Database\Type\TimeTypeTest::testMarshalWithLocaleParsing
Failed asserting that null is not null.
/home/cake/cakephp/tests/TestCase/Database/Type/TimeTypeTest.php:184
/home/cake/cakephp/tests/TestCase/DatabaseSuite.php:68
FAILURES!
Tests: 6777, Assertions: 20613, Errors: 5, Failures: 26, Skipped: 144.
make: *** [test] Error 2
这些问题中的大多数似乎与i18n有关。我希望能够解决这个问题,以便我能够自信地制作PR!