Skip to content

Commit b50ca9d

Browse files
committed
Tests completed
PHPUnit tests succeeded.
1 parent 009a75d commit b50ca9d

File tree

4 files changed

+58
-2
lines changed

4 files changed

+58
-2
lines changed

lib/ezFunctions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ function notIn($x, $y, ...$args)
260260
function between($x, $y, $y2, ...$args)
261261
{
262262
$expression = array();
263-
\array_push($expression, $x, \_BETWEEN, $y, $y2, \_AND, ...$args);
263+
\array_push($expression, $x, \_BETWEEN, $y, $y2, null, \_AND, ...$args);
264264
return $expression;
265265
}
266266

@@ -270,7 +270,7 @@ function between($x, $y, $y2, ...$args)
270270
function notBetween($x, $y, $y2, ...$args)
271271
{
272272
$expression = array();
273-
\array_push($expression, $x, \_notBETWEEN, $y, $y2, \_AND, ...$args);
273+
\array_push($expression, $x, \_notBETWEEN, $y, $y2, null, \_AND, ...$args);
274274
return $expression;
275275
}
276276

tests/pdo/pdo_pgsqlTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,24 @@ public function testSelecting()
189189
}
190190
}
191191

192+
public function testWhereGroup()
193+
{
194+
$this->assertTrue($this->object->connect('pgsql:host=' . self::TEST_DB_HOST . ';dbname=' . self::TEST_DB_NAME . ';port=' . self::TEST_DB_PORT, self::TEST_DB_USER, self::TEST_DB_PASSWORD));
195+
$this->object->query('CREATE TABLE unit_test(id integer, test_key varchar(50), active tinyint(1), PRIMARY KEY (ID))');
196+
$this->object->insert('unit_test', array('id' => '1', 'test_key' => 'testing 1', 'active' => 1));
197+
$this->object->insert('unit_test', array('id' => '2', 'test_key' => 'testing 2', 'active' => 0));
198+
$this->object->insert('unit_test', array('id' => '3', 'test_key' => 'testing 3', 'active' => 1));
199+
$this->object->insert('unit_test', array('id' => '4', 'test_key' => 'testing 4', 'active' => 1));
200+
201+
$result = $this->object->selecting('unit_test', '*', where(eq('active', '1'), whereGroup(like('test_key', '%1%', _OR), like('test_key', '%3%', _OR))));
202+
$i = 1;
203+
foreach ($result as $row) {
204+
$this->assertEquals($i, $row->id);
205+
$this->assertEquals('testing ' . $i, $row->test_key);
206+
$i = $i + 2;
207+
}
208+
}
209+
192210
public function testJoins()
193211
{
194212
$this->assertTrue($this->object->connect('pgsql:host=' . self::TEST_DB_HOST . ';dbname=' . self::TEST_DB_NAME . ';port=' . self::TEST_DB_PORT, self::TEST_DB_USER, self::TEST_DB_PASSWORD));

tests/pdo/pdo_sqliteTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,26 @@ public function testSelecting()
216216
$this->assertEquals(1, $this->object->query('DROP TABLE unit_test'));
217217
}
218218

219+
public function testWhereGroup()
220+
{
221+
$this->assertTrue($this->object->connect('sqlite:' . self::TEST_SQLITE_DB, '', '', array(), true));
222+
$this->object->query('CREATE TABLE unit_test(id integer, test_key varchar(50), active tinyint(1), PRIMARY KEY (ID))');
223+
$this->object->insert('unit_test', array('id' => '1', 'test_key' => 'testing 1', 'active' => 1));
224+
$this->object->insert('unit_test', array('id' => '2', 'test_key' => 'testing 2', 'active' => 0));
225+
$this->object->insert('unit_test', array('id' => '3', 'test_key' => 'testing 3', 'active' => 1));
226+
$this->object->insert('unit_test', array('id' => '4', 'test_key' => 'testing 4', 'active' => 1));
227+
228+
$result = $this->object->selecting('unit_test', '*', where(eq('active', '1'), whereGroup(like('test_key', '%1%', _OR), like('test_key', '%3%', _OR))));
229+
$i = 1;
230+
foreach ($result as $row) {
231+
$this->assertEquals($i, $row->id);
232+
$this->assertEquals('testing ' . $i, $row->test_key);
233+
$i = $i + 2;
234+
}
235+
236+
$this->assertEquals(0, $this->object->query('DROP TABLE unit_test'));
237+
}
238+
219239
public function testJoins()
220240
{
221241
$this->assertTrue($this->object->connect('sqlite:' . self::TEST_SQLITE_DB, '', '', array(), true));

tests/pdo/pdo_sqlsrvTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,24 @@ public function testSelecting()
193193
}
194194
}
195195

196+
public function testWhereGroup()
197+
{
198+
$this->assertTrue($this->object->connect('sqlsrv:Server=' . self::TEST_DB_HOST . ';Database=' . self::TEST_DB_NAME, self::TEST_DB_USER, self::TEST_DB_PASSWORD));
199+
$this->object->query('CREATE TABLE unit_test(id integer, test_key varchar(50), active tinyint(1), PRIMARY KEY (ID))');
200+
$this->object->insert('unit_test', array('id' => '1', 'test_key' => 'testing 1', 'active' => 1));
201+
$this->object->insert('unit_test', array('id' => '2', 'test_key' => 'testing 2', 'active' => 0));
202+
$this->object->insert('unit_test', array('id' => '3', 'test_key' => 'testing 3', 'active' => 1));
203+
$this->object->insert('unit_test', array('id' => '4', 'test_key' => 'testing 4', 'active' => 1));
204+
205+
$result = $this->object->selecting('unit_test', '*', where(eq('active', '1'), whereGroup(like('test_key', '%1%', _OR), like('test_key', '%3%', _OR))));
206+
$i = 1;
207+
foreach ($result as $row) {
208+
$this->assertEquals($i, $row->id);
209+
$this->assertEquals('testing ' . $i, $row->test_key);
210+
$i = $i + 2;
211+
}
212+
}
213+
196214
public function testJoins()
197215
{
198216
$this->assertTrue($this->object->connect('sqlsrv:Server=' . self::TEST_DB_HOST . ';Database=' . self::TEST_DB_NAME, self::TEST_DB_USER, self::TEST_DB_PASSWORD));

0 commit comments

Comments
 (0)