Мой тест должен потерпеть неудачу, но она проходит:phpunit: почему этот assertContains проходит?
public function test_getValidProviderCodes(){
$aTest = PRIDE\Reflection::executeStaticMethodForClassName(Apps_DoctorsReports::class, "getValidProviderCodes");
print_r($aTest);
$this->assertContains("xxxxxxxxxxxxxx", $aTest);
}
Выход:
Testing started at 8:53 AM ...
PHPUnit 4.6.6 by Sebastian Bergmann and contributors.
Configuration read from C:\inetpub\Intranet_Local\phpunit\phpunit.xml
Array
(
[0] => 0
[1] => 1
[2] => 2
[3] => MAYER
[4] => MAY00
[5] => MAYERIC
[6] => COH00
[7] => COH01
[8] => POWELL
[9] => POW00
[10] => JOHN00
[11] => FINO
[12] => POL01
[13] => NONAP
[14] => RAYE00
[15] => HOPS00
[16] => CHAH00
)
-
Time: 1.24 seconds, Memory: 8.25Mb
OK (1 test, 1 assertion)
Значение "xxxxxxxxxxxxxx"
, очевидно, не в этом массиве. Я использовал эту функцию сотни раз и никогда не видел такого поведения.
(Если изменить $aTest
к []
, тест терпит неудачу.)
Это еще один тестовый прогон:
public function test_getValidProviderCodes(){
$aTest = PRIDE\Reflection::executeStaticMethodForClassName(Apps_DoctorsReports::class, "getValidProviderCodes");
$this->assertContains("S01", implode(", ", $aTest));
}
Выход:
Testing started at 9:04 AM ...
PHPUnit 4.6.6 by Sebastian Bergmann and contributors.
Configuration read from C:\inetpub\Intranet_Local\phpunit\phpunit.xml
Failed asserting that '0, 1, 2, M01, M03, M04, M05, N02, C01, C02, C03, C04, P01, P02, P03, P04, P05, P06, P07, R01, H01, J01, J02' contains "S01".
C:\inetpub\Intranet_Local\phpunit\library\classes\apps\DoctorsReportsTest.php:61
Time: 1.54 seconds, Memory: 8.75Mb
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
Hi @Keith, что вы думаете о моих решениях? – Matteo
@Matteo Это хорошо. Я забыл отметить это как принято. –
Hi @Keith, спасибо, добро пожаловать! – Matteo