public function testNestedReport() { $report = new common_report_Report(common_report_Report::TYPE_WARNING, 'test message3'); $sub1 = new common_report_Report(common_report_Report::TYPE_INFO, 'info31'); $sub2 = new common_report_Report(common_report_Report::TYPE_ERROR, 'error31'); $report->add(array($sub1, $sub2)); $this->assertTrue($report->hasChildren()); $this->assertEquals('test message3', (string) $report); $this->assertEquals(common_report_Report::TYPE_WARNING, $report->getType()); $array = array(); foreach ($report as $child) { $array[] = $child; } $this->assertEquals(2, count($array)); list($first, $second) = $array; $this->assertFalse($first->hasChildren()); $this->assertEquals('info31', (string) $first); $this->assertEquals(common_report_Report::TYPE_INFO, $first->getType()); foreach ($first as $child) { $this->fail('Should not contain children'); } $this->assertFalse($second->hasChildren()); $this->assertEquals('error31', (string) $second); $this->assertEquals(common_report_Report::TYPE_ERROR, $second->getType()); foreach ($second as $child) { $this->fail('Should not contain children'); } $this->assertFalse($report->contains(common_report_Report::TYPE_SUCCESS)); $this->assertTrue($report->contains(common_report_Report::TYPE_INFO)); $this->assertTrue($report->contains(common_report_Report::TYPE_ERROR)); }