/** * Find all blocks on a page. * * @param ExhibitPage $page * @return ExhibitPageBlock[] */ public function findByPage($page) { if (!$page->exists()) { return array(); } $select = $this->getSelect()->where('exhibit_page_blocks.page_id = ?', $page->id); return $this->fetchObjects($select); }
/** * Tests to make sure the exhibits controller will return a 404 error for a bad exhibit page slug * **/ public function testNoError404WithGoodExhibitPageSlug() { $exhibits = get_records('Exhibit'); $this->assertEquals(1, count($exhibits)); $exhibit = $exhibits[0]; $exhibit->slug = 'goodexhibitslug'; $exhibit->save(); $this->assertEquals('goodexhibitslug', $exhibit->slug, 'Bad exhibit slug.'); $exhibitPage = new ExhibitPage(); $exhibitPage->title = 'Test Page'; $exhibitPage->order = 1; $exhibitPage->layout = 'image-list-left-thumbs'; $exhibitPage->slug = 'goodexhibitpageslug'; $exhibitPage->exhibit_id = $exhibit->id; $exhibitPage->save(); $this->assertTrue($exhibitPage->exists()); try { $this->dispatch('exhibits/show/goodexhibitslug/goodexhibitpageslug'); } catch (Exception $e) { $this->fail('Should not have thrown a 404 error for a good exhibit page slug.'); } }