_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; } /** * @return Carbon */ public function getCreatedAt() { return $this->_createdAt; } /** * @param Carbon $createdAt */ public function setCreatedAt($createdAt) { $this->_createdAt = $createdAt; } } 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 static(); $array = []; foreach ($json as $data) { $array[] = TestTableDbo::jsonDeserialize($data); } $dbo->setArray($array); return $dbo; } public static function generateSample() { return [ TestTableDbo::generateSample(), TestTableDbo::generateSample() ]; } } class SpTest extends LuStoredProcedure { protected static $_connection = "mydb"; protected static $_storedProcedure = "sp_test"; protected static $_dboClass = LuIntDbo::class; protected static $_dboArrayClass = LuIntDboArray::class; public static function execute($an_int) { return self::getSingle([$an_int]); } } class SpTest2 extends LuStoredProcedure { protected static $_connection = "mydb"; protected static $_storedProcedure = "sp_test2"; protected static $_dboClass = LuIntDbo::class; protected static $_dboArrayClass = LuIntDboArray::class; public static function execute($an_int) { return self::getMultiple([$an_int]); } public static function executePaginated($an_int, $page, $perPage) { return self::getMultiplePaginated([$an_int], $page, $perPage); } } 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(); // var_dump(SpTest::execute(42)); // var_dump(SpTest::execute(4)); // var_dump(SpTest2::execute(42)); // var_dump(SpTest2::executePaginated(42, 0, 2)->jsonSerialize()); // var_dump(SpTest2::executePaginated(42, 1, 2)->jsonSerialize()); // // $dbo = new TestTableDbo(); // $dbo->setId(11); // $dbo->setSomeIntegerArray('{}'); // $dbo->setSomeText("lol2"); // // var_dump(TestTableDataAccess::getMultiple(function(Builder $q) // { // return $q->where("id", "=", 1); // })[0]->jsonSerialize()); // 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'])); // $pdo = TestTableDataAccess::getPdo(); // $pgsql = new PgSqlDataAccess(); // $pgsql->getStoredProceduresFull($pdo); // var_dump($pgsql->getStoredProceduresFull($pdo)); } }