setId(1); return $book; } return null; } /** * fake for test */ public function filterByAuthorSlug($slug = null, $comparison = null) { if ('my-author' === $slug) { $this->byAuthorSlug = true; } return $this; } /** * 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(ConnectionInterface $con = null) { if (true === $this->bySlug) { $book = new Book(); $book->setId(1); $book->setName('My Book'); $book->setSlug('my-book'); return $book; } elseif (true === $this->byAuthorSlug) { $book = new Book(); $book->setId(2); $book->setName('My Kewl Book'); $book->setSlug('my-kewl-book'); return $book; } return null; } } // BookQuery