/** * @expectedException \Corma\Exception\InvalidArgumentException */ public function testMissingTableException() { $this->connection->expects($this->once())->method('createQueryBuilder')->willReturn(new QueryBuilder($this->connection)); $mockStatement = $this->getMockBuilder(Statement::class)->disableOriginalConstructor()->getMock(); $mockStatement->expects($this->once())->method('fetchAll')->willReturn([]); $this->connection->expects($this->once())->method('executeQuery')->willReturn($mockStatement); $this->queryHelper->getDbColumns('asdf'); }
/** * Build parameters for insert or update * @param DataObjectInterface $object * @return array */ protected function buildQueryParams(DataObjectInterface $object) { $queryParams = []; $dbColumns = $this->queryHelper->getDbColumns($object->getTableName()); $data = $object->getData(); foreach ($dbColumns as $column => $acceptNull) { if ($column == 'id') { continue; } if (isset($data[$column])) { $queryParams[$this->db->quoteIdentifier($column)] = $data[$column]; } else { if ($acceptNull) { $queryParams[$this->db->quoteIdentifier($column)] = null; } } } return $queryParams; }