VisualPHPUnit 테스트.VisualPHPUnit - 객체의 속성을 가져올 때 객체가 아닌 객체의 속성을 가져 오려고 시도 중
아니요, 배열이 아닙니다. 또한
class TestGetChildren extends PHPUnit_Framework_TestCase
{
protected $objs;
protected function setUp()
{
$objs = array();
$i=0;
while ($i<20) {
$obj = (object) array (
'ID'=>$i,
'DIRID'=>0
);
if ($i>5) $obj->DIRID = $i-6;
if ($i>10) $obj->DIRID = 7;
$objs[] = $obj;
$i++;
}
$this->objs = $objs;
}
public function testGetChildren() {
$objs = $this->objs;
//var_dump($objs);
print_r(gettype($objs));
assert('array' == gettype($objs));
print_r($objs[19]->ID);
$vm = new FoldersPermissions($objs);
//$children = $vm->getChildren($vm->folders[0]);
foreach ($vm->folders as $obj) {
$children = $vm->getChildren($obj);
print_r($obj->ID."|".count($children)."\n");
// 0 is a special case, and 1 has 10 children
if (4 >= $obj->ID && 1 < $obj->ID) {
//print_r(($children));
$this->assertTrue(1 == count($children));
}
if (7 == $obj->ID){
$this->assertTrue(count($children) == 9);
}
}
}
}
, 출력 :
Debugging Output
19
그래서 실제로 작동합니다. 무엇? 또한
, 분명히 $ OBJS가 배열이 아닌 ...
편집이 명확히하기 :
public function testGetChildren() {
$objs = $this->objs;
//var_dump($objs);
print_r(gettype($objs));
assert('array' == gettype($objs));
및 응답으로이있어 : 나는과 같이 testGetChildren을 변경
NULL 경고 : assert() : 어설 션 실패
$ objs *를 (를) 게시 한 코드에서 배열입니다. $ objs [19]는 그 배열의 요소이며 stdClass의 객체 인 것으로 보입니다. – liquorvicar
당신은 그렇게 생각하지 않을 것입니다. 분명히 그것은 NULL입니다. 흥미롭게도, 테스트가 성공적으로 완료됩니다. – Esa