/**
  * db command return invalid json string
  * @expectedException \UnexpectedValueException
  */
 public function testGetAll5()
 {
     $this->execw->setSocketMatcher('getjson', array())->setExecImplementation(function ($cmd, &$output, &$retval) {
         $retval = 0;
         $output[] = 'xx';
     });
     $this->object->getAll('TT');
 }
Esempio n. 2
0
 private function lazyInitialization()
 {
     $this->data = new \ArrayObject();
     $this->changes = new \ArrayObject();
     // use type filter from DB
     $dbType = count($this->types) === 1 ? $this->types[0] : NULL;
     $rawData = $this->database->getAll($dbType);
     if (!is_array($rawData)) {
         return;
     }
     foreach ($rawData as $key => $row) {
         if (count($this->types) === 1) {
             unset($row['type']);
         } elseif (count($this->types) > 1 && !in_array($row['type'], $this->types)) {
             // skip record if not in required set of types
             continue;
         }
         if ($this->filter === NULL) {
             $this->data[$key] = new \ArrayObject($row);
         } elseif (call_user_func($this->filter, $key, $row)) {
             $this->data[$key] = new \ArrayObject($row);
         }
     }
 }