Skip to content

Commit

Permalink
Fix MockMapper findOne if id doesn't exist.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwinter committed Jul 11, 2012
1 parent bd9e34a commit f32b305
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion classes/TheCure/Mappers/MockMapper.php
Expand Up @@ -122,7 +122,10 @@ function ($where) use ($collection)
{
if (isset($where['_id']))
{
return $collection[$where['_id']];
if (isset($collection[$where['_id']]))
{
return $collection[$where['_id']];
}
}
elseif ($where)
{
Expand Down
6 changes: 6 additions & 0 deletions test/unit/classes/TheCure/Specs/Mappers/Mapper.php
Expand Up @@ -89,6 +89,12 @@ public function testFindNone()
$this->assertNull($collection->current());
}

public function testFindOneWithNonExistentId()
{
$result = static::mapper()->findOne(123);
$this->assertNull($result);
}

public function provideModel()
{
$model = new Models\User;
Expand Down

0 comments on commit f32b305

Please sign in to comment.