From a1ee2f17fb3ccccf3ba720324c1537903b4041b2 Mon Sep 17 00:00:00 2001 From: pairprog <pairprog@afi-sa.fr> Date: Thu, 27 Feb 2014 12:26:43 +0100 Subject: [PATCH] Fix Admin/AlbumControllerTest failures --- .../admin/controllers/AlbumController.php | 5 ++-- .../admin/controllers/AlbumControllerTest.php | 26 +++++++++++++------ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/application/modules/admin/controllers/AlbumController.php b/application/modules/admin/controllers/AlbumController.php index 7cdd4062f97..7dc71a9a2d9 100644 --- a/application/modules/admin/controllers/AlbumController.php +++ b/application/modules/admin/controllers/AlbumController.php @@ -35,8 +35,9 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { public function indexAction() { $categories = Class_AlbumCategorie::findAllBy(['parent_id' => 0, 'order' => 'libelle']); $categories []= Class_AlbumCategorie::newInstanceWithId(0) - ->setLibelle('Albums non classés') - ->setSousCategories([]); + ->setLibelle('Albums non classés') + ->setSousCategories([]) + ->setAlbums(Class_Album::findAllBy(['cat_id' => 0])); $this->view->categories = [['bib' => Class_Bib::getPortail(), 'containers' => $categories]]; diff --git a/tests/application/modules/admin/controllers/AlbumControllerTest.php b/tests/application/modules/admin/controllers/AlbumControllerTest.php index 83c9b64f703..d456b99fa24 100644 --- a/tests/application/modules/admin/controllers/AlbumControllerTest.php +++ b/tests/application/modules/admin/controllers/AlbumControllerTest.php @@ -96,11 +96,13 @@ abstract class Admin_AlbumControllerTestCase extends Admin_AbstractControllerTes ->setRessources([]) ->save(); - $this->fixture('Class_Album', ['id' => 24]) - ->setTitre('Mes Romans') - ->setLangue('') - ->setCategorie($adulte) - ->save(); + $romans = $this->fixture('Class_Album', + ['id' => 24, + 'titre' => 'Mes Romans', + 'langue' => '']); + + $adulte->addAlbum($romans)->assertSave(); + Class_Notice::beVolatile(); Class_Exemplaire::beVolatile(); @@ -124,12 +126,18 @@ class Admin_AlbumControllerIndexTest extends Admin_AlbumControllerTestCase { ->save(); $this->fixture('Class_Album', ['id' => 66, 'titre' => "L'orphelin", - 'parent_id' => 0, 'cat_id' => 0]); $this->dispatch('/admin/album', true); } + /** @test */ + public function categorieAdulteFindAllShouldContainsAlbumMesRomans() { + $cat_adultes = Class_AlbumCategorie::find(6); + $mes_romans = $cat_adultes->getAlbums()[0]; + $this->assertEquals('Mes Romans', $mes_romans->getLibelle()); + } + /** @test */ public function controllerShouldBeAlbum() { $this->assertController('album'); @@ -180,7 +188,7 @@ class Admin_AlbumControllerIndexTest extends Admin_AlbumControllerTestCase { /** @test */ public function albumMesRomansShouldBeInCategorieAdulte() { - $this->assertXPathContentContains("//div[@class='item-label']", 'Mes Romans'); + $this->assertXPathContentContains("//div[@class='item-label']", 'Mes Romans', $this->_response->getBody()); } @@ -264,7 +272,9 @@ class Admin_AlbumControllerIndexTest extends Admin_AlbumControllerTestCase { /** @test */ public function categorieAlbumsNonClassesShouldHaveAlbumOrphelin() { - $this->assertXPathContentContains('//ul[@class="root"]/li[last()]//li', "L'orphelin"); + $this->assertXPathContentContains('//ul[@class="root"]/li[last()]//li', + "L'orphelin", + $this->_response->getBody()); } -- GitLab