@@ -15,13 +15,22 @@ class EngineTest extends \PHPUnit\Framework\TestCase {
1515 protected $ object ;
1616 protected $ lastId = null ;
1717
18+ private function updateLastId () {
19+ $ this ->lastId = $ this ->object ->listingQuery ()->orderBy ('id DESC ' )->limit (1 )->fetchColumn (0 );
20+ }
21+
1822 /**
1923 * Sets up the fixture, for example, opens a network connection.
2024 * This method is called before a test is executed.
2125 */
2226 protected function setUp (): void {
23- $ this ->object = new Engine (null , ['myTable ' => 'test ' , 'createColumn ' => 'created ' , 'lastModifiedColumn ' => 'updated ' ]);
24- $ this ->lastId = $ this ->object ->listingQuery ()->orderBy ('id DESC ' )->limit (1 )->fetchColumn (0 );
27+ $ this ->object = new Engine (null , [
28+ 'myTable ' => 'test ' ,
29+ 'createColumn ' => 'created ' ,
30+ 'lastModifiedColumn ' => 'updated ' ,
31+ 'nameColumn ' => 'key '
32+ ]);
33+ $ this ->updateLastId ();
2534 }
2635
2736 /**
@@ -57,7 +66,8 @@ public function testConstructor() {
5766 * @covers Ease\SQL\Engine::getRecordName
5867 */
5968 public function testGetRecordName () {
60- $ this ->assertEquals ('' , $ this ->object ->GetRecordName ());
69+ $ this ->object ->loadFromSQL (1 );
70+ $ this ->assertEquals ('' , $ this ->object ->getRecordName ());
6171 }
6272
6373 /**
@@ -120,21 +130,21 @@ public function testGetPdo() {
120130 * @covers Ease\SQL\Engine::getFluentPDO
121131 */
122132 public function testGetFluentPDO () {
123- $ this ->assertEquals ('Envms\FluentPDO\Query ' , $ this ->object ->getFluentPDO ());
133+ $ this ->assertInstanceOf ('Envms\FluentPDO\Query ' , $ this ->object ->getFluentPDO ());
124134 }
125135
126136 /**
127137 * @covers Ease\SQL\Engine::listingQuery
128138 */
129139 public function testListingQuery () {
130- $ this ->assertEquals ('Envms\FluentPDO\Queries\Select ' , get_class ( $ this ->object ->listingQuery () ));
140+ $ this ->assertInstanceOf ('Envms\FluentPDO\Queries\Select ' , $ this ->object ->listingQuery ());
131141 }
132142
133143 /**
134144 * @covers Ease\SQL\Engine::getColumnsFromSQL
135145 */
136146 public function testGetColumnsFromSQL () {
137- $ this ->assertEquals ('' , $ this ->object ->GetColumnsFromSQL (['id ' ]));
147+ $ this ->assertEquals ([ 2 => [ ' id ' => 2 ]] , $ this ->object ->getColumnsFromSQL (['id ' ], [ ' id ' => 2 ], ' id ' , ' id ' ));
138148 }
139149
140150 /**
@@ -163,7 +173,7 @@ public function testDbreload() {
163173 */
164174 public function testDbsync () {
165175 $ this ->object ->setData (['id ' => 3 , 'key ' => 'thrid ' , 'value ' => 'newone ' ]);
166- $ this ->assertEquals ( '' , $ this ->object ->dbsync ());
176+ $ this ->assertTrue ( $ this ->object ->dbsync ());
167177 }
168178
169179 /**
0 commit comments