mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-13 04:53:26 +00:00
Add databox_descriptionStructure::toArray method
This commit is contained in:
@@ -118,4 +118,11 @@ class databox_descriptionStructure implements IteratorAggregate
|
|||||||
{
|
{
|
||||||
return isset($this->elements[$id]);
|
return isset($this->elements[$id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function toArray()
|
||||||
|
{
|
||||||
|
return array_map(function ($element) {
|
||||||
|
return $element->toArray();
|
||||||
|
}, array_values($this->elements));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
27
tests/classes/databox/databox_descriptionStructureTest.php
Normal file
27
tests/classes/databox/databox_descriptionStructureTest.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class databox_descriptionStructureTest extends PhraseanetPHPUnitAbstract
|
||||||
|
{
|
||||||
|
public function testToArray()
|
||||||
|
{
|
||||||
|
$structure = new \databox_descriptionStructure();
|
||||||
|
|
||||||
|
$array = array('name1' => 'value1', 'name2' => 'value2');
|
||||||
|
|
||||||
|
$element = $this->provideDataboxFieldMock();
|
||||||
|
$element->expects($this->once())
|
||||||
|
->method('toArray')
|
||||||
|
->will($this->returnValue($array));
|
||||||
|
|
||||||
|
$structure->add_element($element);
|
||||||
|
|
||||||
|
$this->assertEquals(array($array), $structure->toArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
private function provideDataboxFieldMock()
|
||||||
|
{
|
||||||
|
return $this->getMockBuilder('databox_field')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user