Skip to content

Commit

Permalink
fixes unit tests for Query search parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkingmedia committed Jun 28, 2016
1 parent 2d02d68 commit 3053f13
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/ORM/Table.php
Expand Up @@ -1262,13 +1262,15 @@ public function findOrCreate($search, callable $callback = null, $options = [])
*/
protected function _processFindOrCreate($search, callable $callback = null, $options = [])
{
$query = ($search instanceof Query) ? $search : $this->find();
if (is_callable($search)) {
$query = $this->find();
$search($query);
} elseif (is_array($search)) {
$query->where($search);
$query = $this->find()->where($search);
} elseif ($search instanceof Query) {
$query = $search;
} else {
throw new InvalidArgumentException('Search criteria must be an array or callable');
throw new InvalidArgumentException('Search criteria must be an array, callable or Query');
}
$row = $query->first();
if ($row !== null) {
Expand Down

0 comments on commit 3053f13

Please sign in to comment.