2013-07-24 3 views
1

phpunit에서 assertNotEmpty("0")을 수행하면 오류가 발생합니다. "0"은 길이가 1 인 문자열이므로 실패하지 않아야합니다.assertNotEmpty ("0")가 실패합니다. 왜 그럴까요?

다음 테스트가 성공합니다.

$this->assertEquals(1, strlen("0")); 
$this->assertInternalType('string', "0"); 

그렇다면 "0"이 비어 있다고 말하는 이유는 무엇입니까? assert 문은 공백을 검사하기 위해 내부적으로이를 정수로 변환합니까?

다음 일 http://php.net/manual/en/function.empty.php에서

+0

무엇입니까? 설명 할 단어를 조금 추가하십시오. – Geek

답변

6

은 빈 것으로 간주됩니다 :

"" (an empty string) 
0 (0 as an integer) 
0.0 (0 as a float) 
"0" (0 as a string) 
NULL 
FALSE 
array() (an empty array) 
$var; (a variable declared, but without a value)