123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- <?php
- use Carbon\Carbon;
- use Illuminate\Database\Query\Builder;
- use Luticate\Utils\Controller\LuticateApplication;
- use Illuminate\Database\Capsule\Manager as Capsule;
- use Luticate\Utils\DataAccess\LuDataAccess;
- use Luticate\Utils\DataAccess\PgSqlDataAccess;
- use Luticate\Utils\Dbo\LuDbo;
- use Luticate\Utils\Dbo\LuDboDeserializeException;
-
-
-
- class TestTableDbo extends LuDbo
- {
-
-
- private $_id;
-
-
-
- private $_someText;
-
-
-
- private $_someIntegerArray;
-
-
-
- private $_createdAt;
-
-
-
- public function getId()
- {
- return $this->_id;
- }
-
-
-
- public function setId($id)
- {
- $this->_id = $id;
- }
-
-
-
- public function getSomeText()
- {
- return $this->_someText;
- }
-
-
-
- public function setSomeText($someText)
- {
- $this->_someText = $someText;
- }
-
-
-
- public function getSomeIntegerArray()
- {
- return $this->_someIntegerArray;
- }
-
-
-
- public function setSomeIntegerArray($someIntegerArray)
- {
- $this->_someIntegerArray = $someIntegerArray;
- }
-
-
-
- public function getCreatedAt()
- {
- return $this->_createdAt;
- }
-
-
-
- public function setCreatedAt($createdAt)
- {
- $this->_createdAt = $createdAt;
- }
-
- }
-
- class TestTableDboArray extends LuDbo
- {
-
-
- 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 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()
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- }
|