diff --git a/src/Connection.php b/src/Connection.php index e276619a..fd9eae37 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -140,7 +140,11 @@ public function query(...$args): Result /** @inheritdoc */ public function queryArgs($query, array $args = []): Result { - array_unshift($args, $query); + if (is_array($query)) { + $args = $query; + } else { + array_unshift($args, $query); + } return $this->query(...$args); } diff --git a/tests/cases/unit/ConnectionTest.phpt b/tests/cases/unit/ConnectionTest.phpt new file mode 100644 index 00000000..fdcf7dfd --- /dev/null +++ b/tests/cases/unit/ConnectionTest.phpt @@ -0,0 +1,43 @@ +shouldReceive('create')->with(\Mockery::type(Connection::class))->once()->andReturn($sqlProcessor); + $driver->shouldReceive('isConnected')->once()->andReturn(false); + + $connection = new Connection($config); + + $sqlProcessor->shouldReceive('process')->once()->with(['SELECT * FROM %table', 'table'])->andReturn('query'); + $connection->queryArgs(['SELECT * FROM %table', 'table']); + + Environment::$checkAssertions = false; + } +} + + +$test = new ConnectionTest(); +$test->run();