diff --git a/library/Class/Album.php b/library/Class/Album.php index 31e6db70f5282e6fb2696e4a0c924ed1aae5293f..3e36f252e98a6bdc19a804f9fe670ff48effe8a5 100644 --- a/library/Class/Album.php +++ b/library/Class/Album.php @@ -1452,6 +1452,11 @@ class Class_Album extends Storm_Model_Abstract { } + public function isValidated() { + return (self::STATUS_VALIDATED == $this->getStatus()); + } + + public function getIdEad() { return $this->hasIdOrigine() ? $this->getIdOrigine() : 'A' . $this->getId(); } diff --git a/library/Class/Indexation/PseudoNotice.php b/library/Class/Indexation/PseudoNotice.php index ad5c63a1a79c6c16df735ec66c282f166370b21a..d47a47e38d6df8fe1df2f8cb90456a4c69f506cd 100644 --- a/library/Class/Indexation/PseudoNotice.php +++ b/library/Class/Indexation/PseudoNotice.php @@ -437,7 +437,9 @@ class Class_Indexation_PseudoNotice_Album extends Class_Indexation_PseudoNotice{ } public function isValid() { - return null != $this->_model && $this->_model->isVisible(); + return null != $this->_model + && $this->_model->isVisible() + && $this->_model->isValidated(); } } diff --git a/tests/application/modules/admin/controllers/AlbumControllerPharoVideosTest.php b/tests/application/modules/admin/controllers/AlbumControllerPharoVideosTest.php index b644964ebb1336eeff6add240e324d1126dcc4a2..c6502e467c298ece84ff3428d52f3153ea102424 100644 --- a/tests/application/modules/admin/controllers/AlbumControllerPharoVideosTest.php +++ b/tests/application/modules/admin/controllers/AlbumControllerPharoVideosTest.php @@ -25,6 +25,7 @@ abstract class Admin_AlbumControllerPharoVideosTestCase extends Admin_AbstractCo public function setUp() { parent::setUp(); $this->fixture('Class_Album', ['id' =>'777', + 'status' => Class_Album::STATUS_VALIDATED, 'categorie' => $this->fixture('Class_AlbumCategorie',['id'=>1, 'libelle' => 'Languages de prog.']) ]); diff --git a/tests/application/modules/admin/controllers/AlbumControllerTest.php b/tests/application/modules/admin/controllers/AlbumControllerTest.php index 352c01e0262b707e837fb7619a4e80f8da0e2ae8..545c63e7708ea94f097dbad88b4d7f78c9cb9a68 100644 --- a/tests/application/modules/admin/controllers/AlbumControllerTest.php +++ b/tests/application/modules/admin/controllers/AlbumControllerTest.php @@ -95,12 +95,14 @@ abstract class Admin_AlbumControllerTestCase extends Admin_AbstractControllerTes ->setProvenance('Prieuré, Souvigny') ->setCote('MS001') ->setVisible(false) + ->setStatus(Class_Album::STATUS_VALIDATED) ->setNatureDoc('1;3') ->setCategorie($favoris) ->save(); $this->fixture('Class_Album', ['id' => 44]) ->setTitre('Bible Souvigny') + ->setStatus(Class_Album::STATUS_VALIDATED) ->beLivreNumerique() ->setThumbnailAttributes(['thumbnail_width' => 350, 'thumbnail_left_page_crop_left' => 10, @@ -113,6 +115,7 @@ abstract class Admin_AlbumControllerTestCase extends Admin_AbstractControllerTes $romans = $this->fixture('Class_Album', ['id' => 24, 'titre' => 'Mes Romans', + 'status' => Class_Album::STATUS_VALIDATED, 'langue' => '']); $adulte->addAlbum($romans)->assertSave(); @@ -757,6 +760,7 @@ class Admin_AlbumControllerPostAlbumIronMaidenWithoutCategory extends Admin_Albu $this->postDispatch('/admin/album/add_album_to/id/0', ['titre' => 'Iron Maiden', + 'status' => Class_Album::STATUS_VALIDATED, 'sous_titre' => 'The Number of the Beast']); } @@ -815,6 +819,7 @@ class Admin_AlbumControllerPostAlbumRenaissanceToPatrimoineFrbrNoTypeTest 'nature_doc' => '2;3', 'type_doc_id' => '102', 'visible' => '1', + 'status' => Class_Album::STATUS_VALIDATED, 'genre' => '32;23', 'dewey' => '0277;0285', 'pcdm4' => '0683;0684', @@ -855,6 +860,7 @@ class Admin_AlbumControllerPostAlbumRenaissanceToPatrimoineFrbrNoLinkTest 'nature_doc' => '2;3', 'type_doc_id' => '102', 'visible' => '1', + 'status' => Class_Album::STATUS_VALIDATED, 'genre' => '32;23', 'dewey' => '0277;0285', 'pcdm4' => '0683;0684', @@ -982,11 +988,23 @@ class Admin_AlbumControllerPostAlbumRenaissanceToPatrimoineTest /** @test */ - public function newAlbumShouldBeValidated() { + public function newAlbumShouldHaveStatusThree() { $this->assertEquals(3, (int) $this->new_album->getStatus()); } + /** @test */ + public function newAlbumShouldBeValidated() { + $this->assertTrue($this->new_album->isValidated()); + } + + + /** @test */ + public function newAlbumShouldBeIndexed() { + $this->assertNotNull($this->new_album->getNoticeId()); + } + + /** @test */ public function pseudoNoticeShouldBeIndexed() { $this->assertNotNull($this->new_notice); @@ -1201,6 +1219,7 @@ class Admin_AlbumControllerEditAlbumMesBDPostFrbrDeleteTest extends Admin_AlbumC 'nature_doc' => '2;3', 'type_doc_id' => '102', 'visible' => '1', + 'status' => Class_Album::STATUS_VALIDATED, 'genre' => '32;23', 'dewey' => '0277;0285', 'pcdm4' => '0683;0684', @@ -1249,6 +1268,7 @@ class Admin_AlbumControllerEditAlbumMesBDPostFrbrModifyTest extends Admin_AlbumC 'nature_doc' => '2;3', 'type_doc_id' => '102', 'visible' => '1', + 'status' => Class_Album::STATUS_VALIDATED, 'genre' => '32;23', 'dewey' => '0277;0285', 'pcdm4' => '0683;0684', @@ -1637,6 +1657,7 @@ class Admin_AlbumControllerPostEditAlbumMesBDTest extends Admin_AlbumControllerT 'tags' => 'selection', 'type_doc_id' => 201, 'visible' => '1', + 'status' => Class_Album::STATUS_VALIDATED, 'annee' => 1998, 'matiere' => '5;6', 'dewey' => '15', @@ -1770,6 +1791,7 @@ abstract class Admin_AlbumControllerAlbumHarlockTestCase extends Admin_AlbumCont 'Class_Album', ['id' => 999, 'titre' => 'Harlock', + 'status' => Class_Album::STATUS_VALIDATED, 'id_origine' => 'HL22', 'type_doc_id' => Class_TypeDoc::DIAPORAMA, 'categorie' => $this->fixture('Class_AlbumCategorie', ['id' => 999, 'libelle' => '']), @@ -2162,6 +2184,7 @@ class Admin_AlbumControllerAlbumHarlockPostRessourceOneActionTest extends Admin_ $this->postDispatch('/admin/album/edit_ressource/id/1', ['titre' => 'Atlantis', + 'status' => Class_Album::STATUS_VALIDATED, 'description' => 'autre vaisseau', 'link_to' => 'http://www.atlantis.com', 'matiere' => '666', @@ -2419,6 +2442,7 @@ class Admin_AlbumControllerPreviewAlbumMonopageTest extends Admin_AlbumControlle parent::setUp(); Class_Album::newInstanceWithId(56, ['titre' => 'Journal', + 'status' => Class_Album::STATUS_VALIDATED, 'thumbnail_width' => 400, 'thumbnail_crop_left' => 10, 'thumbnail_crop_right' => 5, @@ -2545,6 +2569,7 @@ class Admin_AlbumControllerPreviewFilmArteVODTest extends Admin_AlbumControllerT Class_Album::getLoader() ->newInstanceWithId(102) ->setTitre('Mulholland drive') + ->setStatus(Class_Album::STATUS_VALIDATED) ->beArteVOD() ->setNotes(array( array('field' => '856', @@ -2919,6 +2944,7 @@ class Admin_AlbumControllerAddAlbumToAjaxPostTest extends Admin_AlbumControllerT ['titre' => 'Before The Flood', 'cat_id' => 2, 'visible' => '1', + 'status' => Class_Album::STATUS_DRAFT, 'type_doc_id' => 100, 'frbr_type' => ['1:source'], 'frbr_url' => [ROOT_URL.BASE_URL.'/admin/recherche/viewnotice/id_notice/8/clef/DIAMANTSEMPOISONNES--HENRYA--PAYOT-2007-1/id/8']], true); @@ -2935,6 +2961,12 @@ class Admin_AlbumControllerAddAlbumToAjaxPostTest extends Admin_AlbumControllerT public function shouldHaveCreatedFrbrLinkForBeforeTheFlood() { $this->assertNotNull(Class_FRBR_Link::findFirstBy(['target' => ROOT_URL.BASE_URL.'/admin/recherche/viewnotice/id_notice/8/clef/DIAMANTSEMPOISONNES--HENRYA--PAYOT-2007-1/id/8'])); } + + + /** @test */ + public function albumShouldNotBeIndexed() { + $this->assertNull( Class_Album::findFirstBy(['order'=>'id desc'])->getNotice()); + } } @@ -2947,6 +2979,7 @@ class Admin_AlbumControllerAddAlbumToAjaxPostNoVisibleTest extends Admin_AlbumCo $this->postDispatch('/admin/album/link_album_to/id_notice/8/render/popup', ['titre' => 'Dark', 'visible' => '0', + 'status' => Class_Album::STATUS_VALIDATED, 'type_doc_id' => 100, 'frbr_type' => ['1:source'], 'frbr_url' => [ROOT_URL.BASE_URL.'/admin/recherche/viewnotice/id_notice/8/clef/DIAMANTSEMPOISONNES--HENRYA--PAYOT-2007-1/id/8']], true);