From 9a54fd283d7dacf05ab8c9de3685cd13b0e88f6f Mon Sep 17 00:00:00 2001 From: llaffont <laurent.laffont@gmail.com> Date: Sat, 25 Jan 2014 10:15:33 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20test=20end=20to=20end=20cr=C3=A9ation?= =?UTF-8?q?=20album=20MP3=20=C3=A0=20visu=20notice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/Class/Indexation/PseudoNotice.php | 16 --- library/Class/Notice.php | 11 +- library/ZendAfi/Form/Album.php | 7 +- ...echercheControllerAlbumAudioRecordTest.php | 100 ++++++++++++++++++ tests/library/Class/AlbumTest.php | 4 +- 5 files changed, 116 insertions(+), 22 deletions(-) create mode 100644 tests/application/modules/opac/controllers/RechercheControllerAlbumAudioRecordTest.php diff --git a/library/Class/Indexation/PseudoNotice.php b/library/Class/Indexation/PseudoNotice.php index 604d7647ad4..94033e008ad 100644 --- a/library/Class/Indexation/PseudoNotice.php +++ b/library/Class/Indexation/PseudoNotice.php @@ -299,22 +299,6 @@ class Class_Indexation_PseudoNotice { protected function _dataExist($name) { return array_key_exists($name, $this->_datas); } - - - protected function extractFacettesFromClosures($facettes, $display_facettes) - { - foreach ($display_facettes as $code_facette => $closure) { - $values = array_filter(explode(';', $closure($this->_model))); - array_map( - function($value) use ($code_facette,&$facettes) { - $facettes[]=$code_facette . $value; - }, - $values); - } - - return $facettes; - } - } diff --git a/library/Class/Notice.php b/library/Class/Notice.php index 1190923b8bc..c95e62d4568 100644 --- a/library/Class/Notice.php +++ b/library/Class/Notice.php @@ -167,7 +167,8 @@ class Class_Notice extends Storm_Model_Abstract { 'clef_chapeau' => '', 'facettes' => '', 'url_vignette' => '', - 'url_image' => '']; + 'url_image' => '', + 'date_creation' => '']; public function __construct() { @@ -1765,7 +1766,7 @@ class Class_Notice extends Storm_Model_Abstract { public function isNouveaute() { - return date('Y-m-d H:i:s', self::getTimeSource()->time()) < $this->getDateCreation(); + return date('Y-m-d', self::getTimeSource()->time()) <= substr($this->getDateCreation(), 0, 10); } @@ -1796,6 +1797,12 @@ class Class_Notice extends Storm_Model_Abstract { 'Dans les paniers %s', implode(' - ',$list_panier)); } + + + public function beforeSave() { + if ($this->isNew() and !$this->getDateCreation()) + $this->setDateCreation(date('Y-m-d', $this->getCurrentTime())); + } } ?> \ No newline at end of file diff --git a/library/ZendAfi/Form/Album.php b/library/ZendAfi/Form/Album.php index 9010abe569a..a2bcb44c164 100644 --- a/library/ZendAfi/Form/Album.php +++ b/library/ZendAfi/Form/Album.php @@ -36,6 +36,7 @@ class ZendAfi_Form_Album extends ZendAfi_Form { ->addDisplayGroup(['titre', 'sous_titre', 'cat_id', + 'type_doc_id', 'visible', 'fichier', 'pdf'], @@ -46,8 +47,9 @@ class ZendAfi_Form_Album extends ZendAfi_Form { 'album_desc', ['legend' => $form->_('Description')]) - ->addDisplayGroup(['authors'], - 'authors_editors', + ->addDisplayGroup(['authors', + 'auteur'], + 'authors_editors', ['legend' => $form->_('Auteurs')]) ->addDisplayGroup(['droits', @@ -58,7 +60,6 @@ class ZendAfi_Form_Album extends ZendAfi_Form { 'provenance', 'duration', 'id_langue', - 'type_doc_id', 'nature_doc', 'matiere', 'pcdm4', diff --git a/tests/application/modules/opac/controllers/RechercheControllerAlbumAudioRecordTest.php b/tests/application/modules/opac/controllers/RechercheControllerAlbumAudioRecordTest.php new file mode 100644 index 00000000000..c8a084abbfb --- /dev/null +++ b/tests/application/modules/opac/controllers/RechercheControllerAlbumAudioRecordTest.php @@ -0,0 +1,100 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * AFI-OPAC 2.0 is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * AFI-OPAC 2.0 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with AFI-OPAC 2.0; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +require_once 'AbstractControllerTestCase.php'; + + +abstract class RechercheControllerAlbumAudioRecordTestCase extends AbstractControllerTestCase { + protected $_notice; + + public function setUp() { + parent::setUp(); + + Class_Notice::beVolatile(); + Class_Notice::setTimeSource(new TimeSourceForTest('2014-01-19 09:00:00')); + Class_Exemplaire::beVolatile(); + Class_CodifAuteur::beVolatile(); + + $album = $this->fixture('Class_Album', + ['id' => 4, + 'type_doc_id' => Class_TypeDoc::AUDIO_RECORD, + 'titre' => 'Seventh Son of a Seventh Son']); + $album + ->addAuthor('Iron Maiden') + ->addAuthor('Bruce Dickinson', 'Chanteur') + ->addAuthor('Steve Harris', 'Bassiste') + ->addAuthor('Dave Murray', 'Gutariste') + ->addAuthor('Nicko McBrain', 'Batteur') + ->addAuthor('Adrian Smith', 'Guitariste') + ->addRessource($this->fixture('Class_AlbumRessource', + ['id' => 1, + 'titre' => 'Moonchild', + 'fichier' => 'moonchild.mp3'])) + ->addRessource($this->fixture('Class_AlbumRessource', + ['id' => 2, + 'titre' => 'Infinite Dreams', + 'fichier' => 'infinite_dreams.mp3'])) + ->assertSave(); + + $album->index(); + + $this->_notice = Class_Exemplaire::findFirstBy(['id_origine' => 4])->getNotice(); + } +} + + + + +class RechercheControllerAlbumAudioRecordViewNoticeTest extends RechercheControllerAlbumAudioRecordTestCase { + public function setUp() { + parent::setUp(); + $this->dispatch('/recherche/viewnotice/id/'.$this->_notice->getId(), true); + } + + + /** @test */ + public function noticeShouldNotBeNull() { + $this->assertNotNull($this->_notice); + } + + + /** @test */ + public function dateCreationShouldBe2014_01_19() { + $this->assertEquals('2014-01-19', $this->_notice->getDateCreation()); + } + + + /** @test */ + public function noticeShouldBeNouveaute() { + $this->assertTrue($this->_notice->isNouveaute()); + } + + + /** @test */ + public function titrePrincipalShouldBeSeventhSonOfASeventhSon() { + $this->assertXPathContentContains('//h1', + 'Seventh Son of a Seventh Son', + $this->_response->getBody()); + } +} + +?> \ No newline at end of file diff --git a/tests/library/Class/AlbumTest.php b/tests/library/Class/AlbumTest.php index 8c59e9b51eb..1068299dc82 100644 --- a/tests/library/Class/AlbumTest.php +++ b/tests/library/Class/AlbumTest.php @@ -673,4 +673,6 @@ class AlbumHarlockSortingResourcesTest extends AlbumHarlockTestCase { $this->assertEquals(4, $this->_nausica->getOrdre()); } -} \ No newline at end of file +} + +?> \ No newline at end of file -- GitLab