setId(1); return $book; } return null; } /** * fake for test */ public function filterBySlug($slug = null, $comparison = null) { if ('my-book' == $slug) { $this->bySlug = true; } return $this; } /** * fake for test */ public function filterByName($name = null, $comparison = null) { throw new \Exception('Test should never call this method'); } /** * fake for test */ public function findOne($con = null) { if (true === $this->bySlug) { $book = new Book(); $book->setId(1); $book->setName('My Book'); $book->setSlug('my-book'); return $book; } return null; } } // BookQuery