protected function getDb() { $def = new DatabaseDefinitionBuilder(); $tableDef = new DefinitionBuilder(); $tableDef->a = DataType::string(); $tableDef->b = DataType::string(); $tableDef->c = DataType::string(); $def->addDefinition('Foo', $tableDef); $typeAdapter = $this->getMockBuilder('Jivoo\\Data\\Database\\TypeAdapter')->getMock(); $typeAdapter->method('encode')->willReturnCallback(function ($type, $value) { return '"' . $value . '"'; }); $db = $this->getMockBuilder('Jivoo\\Data\\Database\\Common\\SqlDatabase')->getMock(); $db->method('getTypeAdapter')->willReturn($typeAdapter); $db->method('getDefinition')->willReturn($def); $db->method('sqlLimitOffset')->willReturnCallback(function ($limit, $offset) { if (isset($offset)) { return 'LIMIT ' . $limit . ' OFFSET ' . $offset; } return 'LIMIT ' . $limit; }); $db->method('tableName')->willReturnCallback(function ($table) { return \Jivoo\Utilities::camelCaseToUnderscores($table); }); $db->method('quoteModel')->willReturnCallback(function ($model) { return '{' . $model . '}'; }); $db->method('quoteField')->willReturnCallback(function ($field) { return $field; }); $db->method('quoteLiteral')->willReturnCallback(function ($type, $value) { return '"' . $value . '"'; }); $db->method('quoteString')->willReturnCallback(function ($value) { return '"' . $value . '"'; }); return $db; }
/** * {@inheritdoc} */ public function tableName($name) { return $this->tablePrefix . Utilities::camelCaseToUnderscores($name); }