_id; } /** * @param int $id */ public function setId($id) { $this->_id = $id; } /** * @return string */ public function getSomeText() { return $this->_someText; } /** * @param string $someText */ public function setSomeText($someText) { $this->_someText = $someText; } /** * @return int[] */ public function getSomeIntegerArray() { return $this->_someIntegerArray; } /** * @param int[] $someIntegerArray */ public function setSomeIntegerArray($someIntegerArray) { $this->_someIntegerArray = $someIntegerArray; } } class TestTableDboArray extends LuDbo { /** * @var TestTableDbo[] */ protected $_array; public function getArray() { return $this->_array; } public function setArray($value) { $this->_array = $value; } public function jsonSerialize() { return $this->_array; } public static function jsonDeserialize($json) { if (!is_array($json)) { throw new LuDboDeserializeException("Invalid array value"); } $dbo = new self(); $array = []; foreach ($json as $data) { $array[] = TestTableDbo::jsonDeserialize($data); } $dbo->setArray($array); return $dbo; } public static function generateSample() { return [ TestTableDbo::generateSample(), TestTableDbo::generateSample() ]; } } class TestTableDataAccess extends LuDataAccess { protected static $_connection = "mydb"; protected static $_table = "test_table"; protected static $_dboClass = TestTableDbo::class; protected static $_dboArrayClass = TestTableDboArray::class; } class DatabaseTest extends \PHPUnit_Framework_TestCase { public function testSetup() { // $config = ['databases' => [ // [ // 'name' => 'mydb', // 'driver' => 'pgsql', // 'host' => '172.17.0.1', // 'database' => 'luticate2', // 'username' => 'dev', // 'password' => 'dev' // ] // ]]; // $app = new LuticateApplication($config); // $app->setupDatabases(); // $dbo = new TestTableDbo(); // $dbo->setId(11); // $dbo->setSomeIntegerArray('{}'); // $dbo->setSomeText("lol2"); // var_dump(TestTableDataAccess::getSingleById(1)); // var_dump(TestTableDataAccess::deleteMultiple(function($q) // { // return $q->where("some_text", "=", "lol"); // })); // var_dump(TestTableDataAccess::addSingleId($dbo)); // var_dump(TestTableDataAccess::addSingle($dbo, ['Id'])); // var_dump(TestTableDataAccess::editSingleById($dbo)); // var_dump(TestTableDataAccess::editMultiple($dbo, function($q) // { // return $q->where("some_text", "like", "lol%"); // }, ['Id'])); } }