public function testStaticFindOneReturnsModelInstance() { $collectionName = 'users'; $query = array('email' => '*****@*****.**'); $options = array(); // the return value from the find $usersData = $this->getUserData(); // mock connection methods $this->connectionMock->expects($this->once())->method('findOne')->with($collectionName, $query, $options)->willReturn($usersData); $result = UserUnit::findOne($query, $options); // assertions $this->assertTrue($result instanceof UserUnit); $this->assertEquals($result->name, $usersData['name']); }