Skip to content

Commit

Permalink
Merge pull request #59 from efcor/patch-4
Browse files Browse the repository at this point in the history
fix failing tests
  • Loading branch information
jfelder authored Feb 12, 2021
2 parents c6664b0 + f0beb85 commit af33661
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
15 changes: 10 additions & 5 deletions tests/OracleDBQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,24 +290,29 @@ public function testBasicWheres()
public function testWheresWithArrayValue()
{
$builder = $this->getOracleBuilder();
$builder->select('*')->from('users')->where('id', [12, 30]);
$builder->select('*')->from('users')->where('id', [12]);
$this->assertSame('select * from "users" where "id" = ?', $builder->toSql());
$this->assertEquals([0 => 12, 1 => 30], $builder->getBindings());
$this->assertEquals([0 => 12], $builder->getBindings());

$builder = $this->getOracleBuilder();
$builder->select('*')->from('users')->where('id', '=', [12, 30]);
$this->assertSame('select * from "users" where "id" = ?', $builder->toSql());
$this->assertEquals([0 => 12, 1 => 30], $builder->getBindings());
$this->assertEquals([0 => 12], $builder->getBindings());

$builder = $this->getOracleBuilder();
$builder->select('*')->from('users')->where('id', '!=', [12, 30]);
$this->assertSame('select * from "users" where "id" != ?', $builder->toSql());
$this->assertEquals([0 => 12, 1 => 30], $builder->getBindings());
$this->assertEquals([0 => 12], $builder->getBindings());

$builder = $this->getOracleBuilder();
$builder->select('*')->from('users')->where('id', '<>', [12, 30]);
$this->assertSame('select * from "users" where "id" <> ?', $builder->toSql());
$this->assertEquals([0 => 12, 1 => 30], $builder->getBindings());
$this->assertEquals([0 => 12], $builder->getBindings());

$builder = $this->getOracleBuilder();
$builder->select('*')->from('users')->where('id', '=', [[12, 30]]);
$this->assertSame('select * from "users" where "id" = ?', $builder->toSql());
$this->assertEquals([0 => 12], $builder->getBindings());
}

public function testDateBasedWheresAcceptsTwoArguments()
Expand Down
6 changes: 5 additions & 1 deletion tests/mocks/OCIFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
if (! function_exists("Jfelder\OracleDB\OCI_PDO\oci_error")) {
function oci_error($a = '')
{
return ['code' => 0,'message' => '', 'sqltext' => ''];
global $OCIExecuteStatus, $OCIFetchStatus, $OCITransactionStatus;

return ($OCIExecuteStatus && $OCIFetchStatus && $OCITransactionStatus)
? false
: ['code' => 0,'message' => '', 'sqltext' => ''];
}
}

Expand Down

0 comments on commit af33661

Please sign in to comment.