Ejemplo n.º 1
0
 /**
  *
  * @return databox_descriptionStructure
  */
 public function get_meta_structure()
 {
     if ($this->meta_struct) {
         return $this->meta_struct;
     }
     try {
         $metaStructData = $this->get_data_from_cache(self::CACHE_META_STRUCT);
     } catch (\Exception $e) {
         $sql = 'SELECT id, `name` FROM metadatas_structure ORDER BY sorter ASC';
         $stmt = $this->get_connection()->prepare($sql);
         $stmt->execute();
         $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
         $stmt->closeCursor();
         if ($rs) {
             $metaStructData = $rs;
             $this->set_data_to_cache($metaStructData, self::CACHE_META_STRUCT);
         }
     }
     $this->meta_struct = new databox_descriptionStructure();
     if ($metaStructData) {
         foreach ($metaStructData as $row) {
             $this->meta_struct->add_element(databox_field::get_instance($this->app, $this, $row['id']));
         }
     }
     return $this->meta_struct;
 }
 public function testToArray()
 {
     $structure = new \databox_descriptionStructure();
     $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], $structure->toArray());
 }