diff --git a/application/modules/opac/controllers/BlogController.php b/application/modules/opac/controllers/BlogController.php index f54b71d4b7d75b836bf653f6ae4d8dc1c6deec7d..70b7d0a358d16a4e1a54afff318ffb9477bf580c 100644 --- a/application/modules/opac/controllers/BlogController.php +++ b/application/modules/opac/controllers/BlogController.php @@ -80,6 +80,7 @@ class BlogController extends ZendAfi_Controller_Action { public function lastcritiqueAction() { $nb_avis = (int)$this->_getParam('nb', 20); $liste_avis = Class_AvisNotice::findAllBy(['order' => 'date_avis desc', + 'flags' => Class_AvisNotice::NO_FLAG, 'limit' => $nb_avis]); $this->view->nb_aff = $nb_avis; diff --git a/application/modules/opac/controllers/RssController.php b/application/modules/opac/controllers/RssController.php index 8efa311b86388edd2beb5c780cc7446680ccd99a..3ddbb1cd58be55ca156961e3452385b796ff4328 100644 --- a/application/modules/opac/controllers/RssController.php +++ b/application/modules/opac/controllers/RssController.php @@ -301,10 +301,11 @@ class RssController extends Zend_Controller_Action $avis_helper = $this->view->getHelper('Avis'); - $items = array(); + $items = []; foreach($user_avis as $avis) { $desc = $avis_helper->avis($avis, 0, $vignette_link_to_avis = true); - + if ($desc=='') + continue; $items [] = ['titre' => $avis->getEntete(), 'lien' => $this->view->absoluteUrl([ 'controller' => 'blog', diff --git a/cosmogramme/php/_init.php b/cosmogramme/php/_init.php index 15b3b4cec766c63d85b246f18663819722df8f37..dcd5895a549aae6ff38388ecfabbb1f53252dc5b 100644 --- a/cosmogramme/php/_init.php +++ b/cosmogramme/php/_init.php @@ -1,7 +1,7 @@ <?php error_reporting(E_ERROR | E_PARSE); -define("PATCH_LEVEL","263"); +define("PATCH_LEVEL","264"); define("APPLI","cosmogramme"); define("COSMOPATH", "/var/www/html/vhosts/opac2/www/htdocs"); diff --git a/cosmogramme/php/integre_traite_main.php b/cosmogramme/php/integre_traite_main.php index cf167dda41804d10ca4e4dbc446df3a8ceaf3932..8afab8dcd0aff5fa3b4283310fb77e77a656e8a6 100644 --- a/cosmogramme/php/integre_traite_main.php +++ b/cosmogramme/php/integre_traite_main.php @@ -496,7 +496,19 @@ if (!$mode_cron and $chrono->tempsPasse() > 5) sauveContexte(); startIntegrationPhase('ItemFacets'); -$phase = 8; +$phase = 7.5; + +// ---------------------------------------------------------------- +// Reattach Reviews +// ---------------------------------------------------------------- + +if ($phase == 7.5) { + startIntegrationPhase('Reviews'); + $phase = 8; +} + + + // ---------------------------------------------------------------- // Integration des abonnés diff --git a/cosmogramme/sql/patch/patch_264.php b/cosmogramme/sql/patch/patch_264.php new file mode 100644 index 0000000000000000000000000000000000000000..73c2cc32a6add91c7cd6b3bb8decb2a04db05339 --- /dev/null +++ b/cosmogramme/sql/patch/patch_264.php @@ -0,0 +1,11 @@ +<?php +$adapter = Zend_Db_Table::getDefaultAdapter(); + +try { + $adapter->query('select flags from notices_avis limit 1'); +} catch (Exception $e) { + $adapter->query('ALTER TABLE notices_avis ADD COLUMN flags tinyint default 0'); + $adapter->query('ALTER TABLE notices_avis ADD INDEX (flags)'); +} + +?> \ No newline at end of file diff --git a/library/Class/AvisNotice.php b/library/Class/AvisNotice.php index c4a97f61d2ed9b981d61abe856b36eb1eae89aa6..6eeb31c449fa5327b995b4121571dcccd0aa04fc 100644 --- a/library/Class/AvisNotice.php +++ b/library/Class/AvisNotice.php @@ -67,18 +67,29 @@ class AvisNoticeLoader extends Storm_Model_Loader { } + public function findAllAfter($record_id) { + $where = "id > " . $record_id ; + return Class_AvisNotice::findAllBy(['where' => $where, + 'order' => 'id', + 'limit' => '100']); + } + + /* Renvoie les avis correspondants aux préférences de recherches données - id_catalogue: le catalogue de notices dont on veut récupérer les avis - id_panier: le panier de notices dont on veut récupérer les avis On prends les avis soit du catalogue, soit du panier, soit les dernier avis */ - public function getAvisFromPreferences($preferences, $limit_page=null) { + public function getAvisFromPreferences($preferences, $limit_page=null, $include_orphan = false) { $params = ['order' => 'DATE_AVIS DESC']; - + xdebug_break(); + if (!$include_orphan) + $params['flags'] = Class_AvisNotice::NO_FLAG; $preferences = array_merge(['id_panier' => 0, 'id_catalogue' => 0, - 'abon_ou_bib' => 'all'], + 'abon_ou_bib' => 'all', + ], $preferences); $id_panier = $preferences['id_panier']; @@ -94,7 +105,7 @@ class AvisNoticeLoader extends Storm_Model_Loader { if ($limit_page) $params['limitPage'] = $limit_page; - return Class_AvisNotice::getLoader()->findAllBy($params); + return Class_AvisNotice::findAllBy($params); } @@ -109,6 +120,8 @@ class AvisNoticeLoader extends Storm_Model_Loader { class Class_AvisNotice extends Storm_Model_Abstract { use Trait_Avis, Trait_Translator; + const NO_FLAG=0; + const ORPHAN_FLAG=1; protected $_loader_class = 'AvisNoticeLoader'; protected $_table_name = 'notices_avis'; @@ -117,7 +130,10 @@ class Class_AvisNotice extends Storm_Model_Abstract { protected $_belongs_to = ['user' => ['model' => 'Class_Users', 'referenced_in' => 'id_user']]; - protected $_default_attribute_values = ['statut' => 0]; + protected $_default_attribute_values = ['statut' => 0, + 'flags' => self::NO_FLAG, + 'clef_oeuvre' => '', + 'date_avis' => null]; protected $_notices; protected $_import_mode = false; @@ -173,8 +189,6 @@ class Class_AvisNotice extends Storm_Model_Abstract { public function getNotices() { - if (!isset($this->_notices)) - $this->_notices = $this->_findNoticesByClefOeuvre(); return $this->_notices; } @@ -183,25 +197,24 @@ class Class_AvisNotice extends Storm_Model_Abstract { * Recherche les notices liées à cet avis. Si non trouvé (par exemple l'auteur de la clé * oeuvre à été mis à jour dans le SIGB, essaye de retrouver la notice et réaffecte l'avis */ - protected function _findNoticesByClefOeuvre() { - if ($notices = Class_Notice::findAllBy(['clef_oeuvre' => $this->getClefOeuvre()])) - return $notices; + public function findNoticesByClefOeuvre() { + if ($this->_notices = Class_Notice::findAllBy(['clef_oeuvre' => $this->getClefOeuvre()])) + return $this->_notices; if (!$notices = Class_Notice::findAllBy(['where' => 'clef_oeuvre like "'.$this->getTitreClefOeuvre().'-%"'])) - return []; + return $this->_notices = []; $clef_oeuvre = $notices[0]->getClefOeuvre(); foreach($notices as $notice) { //on assume que les notices ont été retrouvées si elles ont toutes la même clé oeuvre if ($clef_oeuvre !== $notice->getClefOeuvre()) - return []; + return $this->_notices = []; $this ->setClefOeuvre($clef_oeuvre) - ->setModerationNOK() ->save(); } - + $this->_notices=$notices; return $notices; } @@ -217,6 +230,8 @@ class Class_AvisNotice extends Storm_Model_Abstract { public function getFirstNotice() { + if ($this->id_notice>0) + return Class_Notice::find($this->id_notice); $notices = $this->getNotices(); if (count($notices) == 0) return null; diff --git a/library/Class/Cosmogramme/Integration/PhaseReviews.php b/library/Class/Cosmogramme/Integration/PhaseReviews.php new file mode 100644 index 0000000000000000000000000000000000000000..7f2c917b534bc770b5788fa17b68b61a5398be66 --- /dev/null +++ b/library/Class/Cosmogramme/Integration/PhaseReviews.php @@ -0,0 +1,122 @@ +<?php +/** + * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH 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). + * + * BOKEH 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 BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +require_once('cosmogramme/php/classes/classe_notice_integration.php'); + +class Class_Cosmogramme_Integration_PhaseReviews extends Class_Cosmogramme_Integration_PhaseAbstract { + const MY_ID=7.5; + + protected $_label = 'Reviews attachments'; + + public function __construct($phase, $log, $chrono) { + parent::__construct($phase, $log, $chrono); + $this->_previous_records = []; + + } + + + protected function _init($new_phase) { + + $new_phase + ->resetDatas() + ->setData('nombre', 0) + ->setData('pointeur_notice', 0) + ->setData('pointeur', + $last_update_date ? $last_update_date : '0000-00-00 00:00:00'); + + $this->_chrono + ->startOnFile() + ->startOnRecords(); + } + + + public function _execute() { + xdebug_break(); + $this->_setData('pointeur_notice', 0); + while ($records = Class_AvisNotice::findAllAfter($this->_getData('pointeur_notice'))) { + + if (0 == ($this->_getData('nombre') % 100)) + $this->_log->ecrire('<span class="vert"> ' . $this->_getData('nombre') . ' records updated </span>'); + if ($this->_previous_records && (0 == count(array_filter(array_diff($this->_previous_records, $records))))) + break; + + $this->_previous_records = $records; + + $this->runUpdateForRecords($records); + + $this->_resetDbConnection(); + + } + + $this->_log->ecrire('<span class="vert">'. + 'Tous les avis ont été mis à jour :' . + ' pointeur avis : ' . $this->_getData('pointeur_avis') . + ' pointeur : ' . $this->_getData('pointeur') . + '<br>' . $this->_getData('nombre') . ' avis traités.</span>'); + + $msg = '<span class="vert">Temps de traitement : ' + . $this->_chrono->endFile() + . ' (' . $this->_chrono->meanOnFile($this->_getData('nombre'), + 'notices') . ')</span>'; + + $this->_log->ecrire($msg); + + } + protected function runUpdateForRecords($records) { + foreach ($records as $record) { + if ($this->isTimeOut()) + return $this->_resetDbConnection() + ->_phase; + $this->_runOne($record); + + } + } + + + protected function _runOne($record) { + // types starting with 100 are indexed at another phase + + $record->findNoticesByClefOeuvre(); + if ($notice = $record->getFirstNotice()) + $record->setIdNotice($notice->getId())->save(); + + $this->_setData('pointeur_notice', $record->getId()); + $this->_incrementData('nombre'); + + } + + /** @category testing */ + public function noDbReset() { + $this->_db_reset = false; + return $this; + } + protected function _resetDbConnection() { + if (!$this->_db_reset) + return $this; + + Storm_Model_Abstract::unsetLoaders(); + Zend_Db_Table::getDefaultAdapter()->closeConnection(); + setupDatabase(loadConfig()); + gc_collect_cycles(); + return $this; + } + + +} \ No newline at end of file diff --git a/library/Class/Users.php b/library/Class/Users.php index f5dca6e7d9fe166bfe1fa659e1479b7b3b7c4050..78458c16c8c9003e538c072ec610d68b94c22c17 100644 --- a/library/Class/Users.php +++ b/library/Class/Users.php @@ -627,6 +627,7 @@ class Class_Users extends Storm_Model_Abstract { public function getLastAvis() { return Class_AvisNotice::findAllBy(['id_user' => $this->getId(), 'order' => 'date_avis desc', + 'flags' => Class_AvisNotice::NO_FLAG, 'limit' => 10]); } diff --git a/library/ZendAfi/View/Helper/Avis.php b/library/ZendAfi/View/Helper/Avis.php index 654ad437334c983bc22312237ec73a3aacc8cc57..9140d8b1bec05de234f807d20da60161cc26ac0d 100644 --- a/library/ZendAfi/View/Helper/Avis.php +++ b/library/ZendAfi/View/Helper/Avis.php @@ -63,7 +63,7 @@ class ZendAfi_View_Helper_Avis extends ZendAfi_View_Helper_BaseHelper { $this->setLimitNbWord($limit_nb_word); return ($avis->isAvisNotice()) ? - $this->avisNotice($avis, $limit_nb_word, $vignette_link_to_avis) : + $this->avisNotice($avis) : $this->avisCms($avis); } @@ -86,18 +86,19 @@ class ZendAfi_View_Helper_Avis extends ZendAfi_View_Helper_BaseHelper { } - protected function avisNotice($avis, $vignette_link_to_avis) { + protected function avisNotice($avis) { $url_vignette = URL_ADMIN_IMG . 'supports/vignette_vide.gif'; $title = $this->_('Oeuvre non trouvée'); - if (null !== $notice = $avis->getFirstNotice()) { - $title = $notice->getTitrePrincipal(); + $notice = $avis->getFirstNotice(); + if ((null !==$notice)) + { + $title = $notice->getTitrePrincipal(); - if (strlen($auteur_principal = $notice->getAuteurPrincipal()) > 0) - $title .= ' (' . $auteur_principal . ')'; - - $url_vignette = $notice->fetchUrlVignette(); - } + if (strlen($auteur_principal = $notice->getAuteurPrincipal()) > 0) + $title .= ' (' . $auteur_principal . ')'; + $url_vignette = $notice->fetchUrlVignette(); + } $content = $this->contenu_avis($avis); return $this-> diff --git a/tests/application/modules/opac/controllers/AbonneControllerAvisTest.php b/tests/application/modules/opac/controllers/AbonneControllerAvisTest.php index b678eae6443f6a10e55afc965d81ee337b751a38..9b161b7c3420fcd1e65b8f0f6db01f4399584e3a 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerAvisTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerAvisTest.php @@ -21,6 +21,8 @@ require_once 'AbstractControllerTestCase.php'; abstract class AbonneFlorenceIsLoggedControllerTestCase extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + protected function _initProfilHook($profil) { $profil ->setBrowser('opac') @@ -30,19 +32,23 @@ abstract class AbonneFlorenceIsLoggedControllerTestCase extends AbstractControll public function setUp() { parent::setUp(); - Class_Users::beVolatile(); - Class_AvisNotice::beVolatile(); - Class_Notice::beVolatile(); - $this->florence = Class_Users::newInstanceWithId(123456) - ->setPseudo('FloFlo') - ->setRoleLevel(2) - ->setRole('abonne_sigb') - ->setLogin('florence') - ->setPassword('caramel') - ->setIdSite(1) - ->setIdabon('00123') - ->setFicheSIGB(['type_com' => 0]); - $this->florence->save(); + $this->fixture('Class_AdminVar', + ['id' => 'AVIS_MIN_SAISIE', + 'valeur' => 0]); + $this->fixture('Class_AdminVar', + ['id' => 'AVIS_MAX_SAISIE', + 'valeur' => 1000]); + + $this->florence = $this->fixture('Class_Users', + ['id' => 123456, + 'pseudo' => 'FloFlo', + 'role_level' => 2, + 'role' => 'abonne_sigb', + 'login' => 'florence', + 'password' => 'caramel', + 'id_site' => 1, + 'idabon' => '00123', + 'fiche_sigb' => ['type_com' => 0]]); ZendAfi_Auth::getInstance()->logUser($this->florence); @@ -207,12 +213,12 @@ class AbonneControllerAvisNoticeWithAvisTest extends AbonneControllerAvisTestCas public function setUp() { parent::setUp(); - $avis = Class_AvisNotice::newInstanceWithId(12, ['Avis' => 'Excellent livre', - 'Entete' => 'Le sorcier super mimi', - 'note' => 4, - 'clef_oeuvre' => 'POTTER', - 'user' => $this->florence]); - $avis->save(); + $avis = $this->fixture('Class_AvisNotice', ['id' => 12, + 'Avis' => 'Excellent livre', + 'Entete' => 'Le sorcier super mimi', + 'note' => 4, + 'clef_oeuvre' => 'POTTER', + 'user' => $this->florence]); $this->dispatch('/opac/abonne/avis/id_notice/53'); $this->_xpath = new Storm_Test_XPath(); $this->_json = json_decode($this->_response->getBody()); @@ -250,105 +256,128 @@ abstract class AvisControllersFixturesTestCase extends AbonneFlorenceIsLoggedCon public function setUp() { parent::setUp(); - $this->modo_avis = new Class_AdminVar(); - $this->modo_avis - ->setId('MODO_AVIS') - ->setValeur(0); - $this->modo_avis_biblio = new Class_AdminVar(); - $this->modo_avis_biblio - ->setId('MODO_AVIS_BIBLIO') - ->setValeur(0); + $this->fixture('Class_AdminVar', + ['id' => 'MODO_AVIS', + 'valeur' => 0]); - $this->readspeaker = new Class_AdminVar(); - $this->readspeaker - ->setId('ID_READ_SPEAKER') - ->setValeur('54QCJRHZ31IPBV7GW3DKBPUYYP579A14'); + $this->fixture('Class_AdminVar', + ['id' => 'MODO_AVIS_BIBLIO', + 'valeur' => 0]); + $this->fixture('Class_AdminVar', + ['id' => 'ID_READ_SPEAKER', + 'valeur' => '54QCJRHZ31IPBV7GW3DKBPUYYP579A14']); - Class_AdminVar::getLoader() - ->cacheInstance($this->modo_avis) - ->cacheInstance($this->modo_avis_biblio) - ->cacheInstance($this->readspeaker); - $this->millenium = Class_Notice::newInstanceWithId(816, ['titre_principal' => 'Millenium', - 'clef_alpha' => 'MILLENIUM', - 'auteur_principal' => 'Stieg Larsson', - 'url_vignette' => '', - 'url_image' => '' - ] + $this->millenium = $this->fixture('Class_Notice', ['id' => 816, + 'titre_principal' => 'Millenium', + 'clef_alpha' => 'MILLENIUM', + 'auteur_principal' => 'Stieg Larsson', + 'url_vignette' => '', + 'url_image' => '' + ] ); - $this->millenium->save(); - $this->millenium_with_vignette = Class_Notice::newInstanceWithId(817, ['titre_principal' => 'Millenium', - 'clef_alpha' => 'MILLENIUM', - 'auteur_principal' => 'Stieg Larsson', - 'url_vignette' => 'http://amazon.com/vignette_millenium.png' - ] + + + + + $this->millenium_with_vignette = $this->fixture('Class_Notice', ['id' => 817, + 'titre_principal' => 'Millenium', + 'clef_alpha' => 'MILLENIUM', + 'auteur_principal' => 'Stieg Larsson', + 'url_vignette' => 'http://amazon.com/vignette_millenium.png' + ] ); - $this->millenium_with_vignette->save(); + $this->avis_millenium = $this->fixture('Class_AvisNotice', ['id' => 13, 'entete' => "J'adore", - 'avis' => '<div><ul><li>Suspense Intense !</li><li>Suspense Intense !</li></ul></div>', - 'note' => 5, - 'date_avis' => '2011-03-18 13:00:00', - 'user' => $this->florence, - 'statut' => 0, - 'abon_ou_bib'=>1 , - 'notices' => [$this->millenium, - $this->millenium_with_vignette] ]); - - $this->avis_millenium->save(); - $this->potter = Class_Notice::newInstance(); - $this->potter - ->setTitrePrincipal('Potter et la chambre des secrets') - ->setAuteurPrincipal('') - ->setUrlVignette('http://amazon.com/vignette_potter.png'); - $this->potter->save(); - $this->avis_potter = Class_AvisNotice::newInstanceWithId(25, - ['entete' => 'Prenant', - 'avis' => "Mais un peu trop naïf", - 'note'=>4, - 'date_avis' => '2010-10-12 10:00:00', - 'user'=>$this->florence, - 'statut' => 1, - 'abon_out_bib' => 1, - 'notices' => [$this->potter]]); - - $this->avis_potter->save(); - - $this->avis_lost = Class_AvisNotice::newInstanceWithId(67, - ['entete' =>"C'est perdu", - 'avis' =>"Plus de notice, ni d'utilisateur", - 'note' => 4, - 'date_avis' => '2008-10-12 10:00:00', - 'user'=>null, - 'statut' => 1, - 'abon_out_bib' => 1, - 'notices' => []]); - $this->avis_lost->save(); - - - $this->florence->setAvis([$this->avis_millenium, $this->avis_potter]); - $this->florence->save(); - $dupont = Class_Users::newInstanceWithId(56, ['nom'=>'Dupont']); - - $avis_millenium_dupont = Class_AvisNotice::newInstanceWithId(156) - ->setEntete("Cool") - ->setAvis("effrayant") - ->setNote(5) - ->setDateAvis('2011-03-18 13:00:00') - ->setAuteur($dupont) - ->setUser($dupont) - ->setStatut(0) - ->setAbonOuBib(1) - ->setNotices([$this->millenium]); - $dupont->setAvis([$avis_millenium_dupont]); - $dupont->save(); - $avis_millenium_dupont->save(); + 'avis' => '<div><ul><li>Suspense Intense !</li><li>Suspense Intense !</li></ul></div>', + 'note' => 5, + 'date_avis' => '2011-03-18 13:00:00', + 'user' => $this->florence, + 'statut' => 0, + 'abon_ou_bib'=>1 , + 'notices' => [$this->millenium, + $this->millenium_with_vignette] ]); + + $this->potter = $this->fixture('Class_Notice', + ['id'=> 22, + 'titre_principal' => 'Potter et la chambre des secrets', + 'auteur_principal' => '', + 'url_vignette' => 'http://amazon.com/vignette_potter.png']); + + $this->avis_potter = $this->fixture('Class_AvisNotice', + ['id' => 25, + 'entete' => 'Prenant', + 'avis' => "Mais un peu trop naïf", + 'note'=>4, + 'date_avis' => '2010-10-12 10:00:00', + 'user'=>$this->florence, + 'statut' => 1, + 'abon_out_bib' => 1, + 'notices' => [$this->potter]]); + + $lost=$this->fixture('Class_AvisNotice', ['id' => 178, + 'entete' => "Lost highway", + 'clef_oeuvre' => 'LOST-LOST', + 'avis' => 'Oh po po !', + 'note' => 5, + 'date_avis' => '2015-03-18 13:00:00', + 'user' => $this->florence, + 'statut' => 1, + 'flags' => Class_AvisNotice::ORPHAN_FLAG, + 'abon_ou_bib'=>1, + 'id_notice' => 30]); + + + $this->avis_lost = $this->fixture('Class_AvisNotice', + ['id' => 67, + 'entete' =>"C'est perdu", + 'avis' =>"Plus de notice, ni d'utilisateur", + 'note' => 4, + 'date_avis' => '2008-10-12 10:00:00', + 'user'=>null, + 'statut' => 1, + 'abon_out_bib' => 1, + 'flags' => 1, + 'notices' => []]); + + + + $dupont = $this->fixture('Class_Users', ['id' => 56 , + 'login' => 'Dupont', + 'nom'=>'Dupont', + 'password' => 'pwd', + 'id_abon' => 435]); + + + $avis_millenium_dupont = $this->fixture('Class_AvisNotice', + ['id' => 156, + 'entete' => "Cool", + 'avis' => "effrayant", + 'note' => 5, + 'setDateAvis' => '2011-03-18 13:00:00', + 'auteur' => $dupont, + 'user' => $dupont, + 'statut' => 0, + 'abon_out_bib' => 1, + 'notices' =>[$this->millenium] + ]); + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Notice') + ->whenCalled('findAllBy') + ->with(['where' => 'clef_oeuvre like "LOST-%"']) + ->answers(null) + ->whenCalled('findAllBy') + ->with(['where' => 'clef_oeuvre like "MILLENIUM-%"']) + ->answers([$this->millenium,$this->millenium_with_vignette]) + ; + + } } @@ -381,9 +410,9 @@ class AbonneControllerAvisViewFicheWithAvisTest extends AvisControllersFixturesT } /** @test */ - public function pageShouldDisplayVousAvezRedigeDeuxAvis() { + public function pageShouldDisplayVousAvezRedigeTroiAvis() { $this->assertXPathContentContains('//a', - 'Vous avez rédigé 2 avis', + 'Vous avez rédigé 3 avis', $this->_response->getBody()); } @@ -392,6 +421,8 @@ class AbonneControllerAvisViewFicheWithAvisTest extends AvisControllersFixturesT public function linkAvisShouldGoToAbonneViewAvis() { $this->assertXPath('//a[contains(@href, "/abonne/viewavis/id/123456")]'); } + + } @@ -400,26 +431,36 @@ class AbonneControllerAvisViewFicheWithAvisTest extends AvisControllersFixturesT class AbonneControllerAvisBlogControllerViewAuteurActionTest extends AvisControllersFixturesTestCase { public function setUp() { parent::setUp(); + + $this->dispatch('/opac/blog/viewauteur/id/123456'); } + + /** @test */ + public function AvisWithoutNoticeShouldBeDisplayedForAuthor() { + $this->assertXPathContentContains("//div[@class='critique'][1]//a", 'Lost highway'); + } + + public function testPageIsRendered() { $this->assertController('blog'); $this->assertAction('viewauteur'); } public function testMilleniumIsHere() { - $this->assertXPathContentContains("//div[@class='critique'][1]//h2", 'Millenium (Stieg Larsson)'); + $this->assertXPathContentContains("//div[@class='critique'][2]//h2", 'Millenium (Stieg Larsson)'); } + /** @test */ public function milleniumShouldLinkToNoticeMilleniumWithRetourAbonneViewAvis() { - $this->assertXPath('//a[contains(@href, "/recherche/viewnotice/id/817/clef/MILLENIUM/retour_abonne/viewavis")]',$this->_response->getBody()); + $this->assertXPath('//a[contains(@href, "/recherche/viewnotice/id/817/clef/MILLENIUM/retour_abonne/viewavis")]'); } public function testPotterIsHere() { - $this->assertXPathContentContains("//div[@class='critique'][2]//h2", 'Potter et la chambre des secrets'); + $this->assertXPathContentContains("//div[@class='critique'][3]//h2", 'Potter et la chambre des secrets'); } public function testDeleteMilleniumButtonPresent() { @@ -504,7 +545,7 @@ class AbonneControllerAvisRssControllerViewAvisUserTest extends AvisControllersF /** @test */ function firstItemTitleShouldBeJAdore() { - $this->assertXPathContentContains('//channel/item/title', "J'adore"); + $this->assertXPathContentContains('//channel/item/title', "J'adore",$this->_response->getBody()); } @@ -601,8 +642,8 @@ class AbonneControllerAvisBlogControllerLastCritiquesTest extends AvisController /** @test */ - public function lostRratingShouldBeAtThirdPlace() { - $this->assertXPathContentContains("//div[@class='critique'][3]//h2", 'Oeuvre non trouvée'); + public function lostRratingShouldNotBeDIsplayed() { + $this->assertNotXPathContentContains("//div[@class='critique'][3]//h2", 'Oeuvre non trouvée'); } } @@ -612,21 +653,16 @@ abstract class ModuleSelectionCritiquesTestCase extends AvisControllersFixturesT public function setUp() { parent::setUp(); - $preferences = array('modules' => array(3 => array('division' => 2, - 'type_module' => 'CRITIQUES', - 'preferences' => array('titre' => 'Coups de coeur' - )))); - $profil = Class_Profil::getLoader() - ->find(2) - ->setCfgModules( ['blog' => ['viewcritiques' => ['nb_display' => 2]]]) - ->setCfgAccueil($preferences); + $preferences = ['modules' => [3 => ['division' => 2, + 'type_module' => 'CRITIQUES', + 'preferences' => ['titre' => 'Coups de coeur' + ] + ]]]; + $profil = $this->fixture('Class_Profil', + ['id'=>2, + 'cfg_modules' => ['blog' => ['viewcritiques' => ['nb_display' => 2]]], + 'cfg_accueil' => $preferences]); - $this->_generateLoaderFor('Class_AvisNotice', ['getAvisFromPreferences']) -// ->expects($this->once()) - ->method('getAvisFromPreferences') - ->will($this->returnValue([$this->avis_millenium, - $this->avis_potter, - $this->avis_lost])); } } @@ -665,11 +701,11 @@ class AbonneControllerAvisBlogControllerViewCritiquesTest extends ModuleSelectio } public function testMilleniumIsHere() { - $this->assertQueryContentContains('h2', 'Millenium'); + $this->assertQueryContentContains('h2', 'Millenium',$this->_response->getBody()); } public function testPotterIsHere() { - $this->assertQueryContentContains('h2', 'Potter'); + $this->assertQueryContentContains('h2', 'Potter',$this->_response->getBody()); } /** @test */ @@ -781,15 +817,16 @@ class AbonneControllerAvisBlogControllerViewReadAvisTest extends AbonneFlorence class AbonneControllerEditAvisNoticeNotFoundActionTest extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; public function setUp() { parent::setUp(); - Class_AvisNotice::beVolatile(); $this->dispatch('/opac/abonne/editavisnotice/id/54', true); } /** @test */ public function responseShouldReloadPage() { + xdebug_break(); $this->assertTrue(false !== strpos(json_decode($this->_response->getBody())->title, 'Sauvegarde en cours')); } } diff --git a/tests/application/modules/opac/controllers/BlogControllerTest.php b/tests/application/modules/opac/controllers/BlogControllerTest.php index 8ccc8b87621b11a5442ee55904e17d671b5003b5..c01c62513941be41e1a273e92b26b1c476e153ab 100644 --- a/tests/application/modules/opac/controllers/BlogControllerTest.php +++ b/tests/application/modules/opac/controllers/BlogControllerTest.php @@ -68,8 +68,10 @@ class BlogControllerHierarchicalTest extends AbstractControllerTestCase { $this->fixture('Class_AvisNotice', ['id' => 1, + 'id_notice' => 233134, 'note' => 5, 'entete' => 'Incroyable', + 'id_notice' => $this->ksp->getId(), 'avis' => 'What a wonderful game', 'statut' => 1, 'date_avis' => '2015-05-18 00:00:00', @@ -143,7 +145,7 @@ class BlogControllerHierarchicalTest extends AbstractControllerTestCase { /** @test */ public function kspShouldBePresent() { - $this->assertXPathContentContains('//h2', 'Kerbal Space Program'); + $this->assertXPathContentContains('//h2', 'Kerbal Space Program',$this->_response->getBody()); } diff --git a/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php b/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php index b87bdc6d4b43d25eb881292c8d96b92e06f22434..779e101872d096abfdab79c0835153f85d30d91c 100644 --- a/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php +++ b/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php @@ -48,7 +48,6 @@ abstract class ProfilOptionsControllerWithProfilAdulteTestCase extends AbstractC 'clef_oeuvre' => 'HPELPA', 'clef_alpha' => 'POTTER', 'exemplaires' => []])]); - $this->setUpProfilAdulte(); $this->setUpProfilJeunesse(); } diff --git a/tests/library/Class/AvisNoticeTest.php b/tests/library/Class/AvisNoticeTest.php index 3a39385cacf05c9aae66d4076c55fba38398f0e9..4ba7297a05416b8aaf41bd399c007bd02ab605cc 100644 --- a/tests/library/Class/AvisNoticeTest.php +++ b/tests/library/Class/AvisNoticeTest.php @@ -367,39 +367,35 @@ class AvisTestFindAllByUserAndClefOeuvreTestCase extends AvisTestFindAllTestCase class NoticeTestHasManyAvisTest extends Storm_Test_ModelTestCase { public function setUp() { - $this->millenium = Class_Notice::newInstanceWithId(34, ['clef_oeuvre' => 'MILLENIUM--LARSSON']); + $this->millenium = $this->fixture('Class_Notice', ['id' => 34, + 'clef_oeuvre' => 'MILLENIUM--LARSSON']); $this->steve = Class_Users::newInstanceWithId(5, ['prenom' => 'Steve']); - $this->avis_millenium_steve = Class_AvisNotice::newInstanceWithId(12, - ['user' => $this->steve, - 'entete' => 'ça fait peur', - 'avis' => "c'est glauque", - 'clef_oeuvre' => 'MILLENIUM--LARSSON', - 'note' => 2]); - - $this->bryan = Class_Users::newInstanceWithId(6, ['prenom' => 'Bryan']); - $this->avis_millenium_lost_bryan = Class_AvisNotice::newInstanceWithId(15, - ['user' => $this->bryan, - 'entete' => 'perdu', - 'avis' => "perdu sniff sniff", - 'clef_oeuvre' => 'MILLENIUM--SLARSSON', - 'note' => 5]); - - - $this->avis_loader = Storm_Test_ObjectWrapper::onLoaderOfModel('Class_AvisNotice'); - $this->avis_loader->whenCalled('save')->answers(true); + $this->avis_millenium_steve = $this->fixture('Class_AvisNotice', ['id' => 12, + 'user' => $this->steve, + 'entete' => 'ça fait peur', + 'avis' => "c'est glauque", + 'clef_oeuvre' => 'MILLENIUM--LARSSON', + 'note' => 2]); + + $this->bryan = $this->fixture('Class_Users' , ['id' =>6, 'login' => 'bryan', 'password' => 'toto', 'prenom' => 'Bryan']); + $this->avis_millenium_lost_bryan = $this->fixture('Class_AvisNotice', ['id' =>15, + 'user' => $this->bryan, + 'entete' => 'perdu', + 'avis' => "perdu sniff sniff", + 'clef_oeuvre' => 'MILLENIUM--SLARSSON', + 'note' => 5]); + + + //$this->avis_loader = Storm_Test_ObjectWrapper::onLoaderOfModel('Class_AvisNotice'); + // $this->avis_loader->whenCalled('save')->answers(true); $this->notice_loader = Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Notice'); + } /** @test */ public function noticeMilleniumGetAvisForUserSteveShouldReturnAvisSteve() { - $this->avis_loader - ->whenCalled('findAllBy') - ->with(['clef_oeuvre' => 'MILLENIUM--LARSSON', - 'id_user' => 5]) - ->answers([$this->avis_millenium_steve]); - $found_avis = $this->millenium->getAvisByUser($this->steve); $this->assertEquals([$this->avis_millenium_steve], $found_avis); @@ -408,31 +404,18 @@ class NoticeTestHasManyAvisTest extends Storm_Test_ModelTestCase { /** @test */ public function noticeMilleniumGetAvisShouldReturnAllAvisOnClefOeuvre() { - $avis_millenium_robert = new Class_AvisNotice(); - - $this->avis_loader - ->whenCalled('findAllBy') - ->with(['clef_oeuvre' => 'MILLENIUM--LARSSON']) - ->answers([$this->avis_millenium_steve, - $avis_millenium_robert]); - $found_avis = $this->millenium->getAvis(); - $this->assertEquals([$this->avis_millenium_steve, - $avis_millenium_robert], + $this->assertEquals([$this->avis_millenium_steve + ], $found_avis); } + /** @test */ public function avisMilleniumSteveGetNoticesShouldReturnNoticeMillenium() { - $this->notice_loader - ->whenCalled('findAllBy') - ->with(['clef_oeuvre' => 'MILLENIUM--LARSSON']) - ->answers([$this->millenium]); - - $notices_found = $this->avis_millenium_steve->getNotices(); - $this->assertEquals(array($this->millenium), - $notices_found); + $notices_found = $this->avis_millenium_steve->findNoticesByClefOeuvre(); + $this->assertEquals(array($this->millenium), $notices_found); } @@ -447,28 +430,29 @@ class NoticeTestHasManyAvisTest extends Storm_Test_ModelTestCase { ->with(['where' => 'clef_oeuvre like "MILLENIUM-%"']) ->answers([$this->millenium]) ->beStrict(); - + $this->avis_millenium_lost_bryan->setStatut(1); + $this->avis_millenium_lost_bryan->findNoticesByClefOeuvre(); $this->assertEquals([$this->millenium], $this->avis_millenium_lost_bryan->getNotices()); - return $this->avis_loader->getFirstAttributeForLastCallOn('save'); + return $this->avis_millenium_lost_bryan; } - - /** + /** * @test * @depends lostAvisMilleniumGetNoticesShouldSearchNoticeOnTitleClefOeuvre */ - public function avisLostShouldBeSaved($saved_avis) { - $this->assertEquals('MILLENIUM--LARSSON', $saved_avis->getClefOeuvre()); + public function ModerationShouldNotBeReset($saved_avis) { + $this->assertEquals(1, $saved_avis->getStatut()); } + /** * @test * @depends lostAvisMilleniumGetNoticesShouldSearchNoticeOnTitleClefOeuvre */ - public function avisLostShouldGoThroughModeration($saved_avis) { - $this->assertEquals(0, $saved_avis->getStatut()); + public function avisLostShouldBeSaved($saved_avis) { + $this->assertEquals('MILLENIUM--LARSSON', $saved_avis->getClefOeuvre()); } } @@ -602,14 +586,14 @@ class AvisLoaderGetAvisFromPreferencesTest extends AvisTestFindAllTestCase { public function testDefaultSQLQuery() { $this->assertQueryIs("SELECT `notices_avis`.* ". "FROM `notices_avis` ". - "ORDER BY `DATE_AVIS` DESC"); + "WHERE (flags=0) ORDER BY `DATE_AVIS` DESC"); } public function testWithAllAndModoAPosteriori() { $this->preferences['abon_ou_bib'] = 'all'; $this->assertQueryIs("SELECT `notices_avis`.* ". "FROM `notices_avis` ". - "ORDER BY `DATE_AVIS` DESC"); + "WHERE (flags=0) ORDER BY `DATE_AVIS` DESC"); } @@ -618,7 +602,7 @@ class AvisLoaderGetAvisFromPreferencesTest extends AvisTestFindAllTestCase { $this->preferences['abon_ou_bib'] = 'all'; $this->assertQueryIs("SELECT `notices_avis`.* ". "FROM `notices_avis` ". - "WHERE ((STATUT=1 OR ABON_OU_BIB=1)) ". + "WHERE (flags=0) AND ((STATUT=1 OR ABON_OU_BIB=1)) ". "ORDER BY `DATE_AVIS` DESC"); } @@ -628,7 +612,7 @@ class AvisLoaderGetAvisFromPreferencesTest extends AvisTestFindAllTestCase { $this->preferences['abon_ou_bib'] = 'all'; $this->assertQueryIs("SELECT `notices_avis`.* ". "FROM `notices_avis` ". - "WHERE ((STATUT=1 OR ABON_OU_BIB=0)) ". + "WHERE (flags=0) AND ((STATUT=1 OR ABON_OU_BIB=0)) ". "ORDER BY `DATE_AVIS` DESC"); } @@ -641,7 +625,7 @@ class AvisLoaderGetAvisFromPreferencesTest extends AvisTestFindAllTestCase { $this->assertQueryIs("SELECT `notices_avis`.* ". "FROM `notices_avis` ". - "WHERE ((STATUT=1 OR ABON_OU_BIB=1) ". + "WHERE (flags=0) AND ((STATUT=1 OR ABON_OU_BIB=1) ". "AND (STATUT=1 OR ABON_OU_BIB=0)) ". "ORDER BY `DATE_AVIS` DESC"); } @@ -651,7 +635,7 @@ class AvisLoaderGetAvisFromPreferencesTest extends AvisTestFindAllTestCase { $this->preferences['abon_ou_bib'] = '0'; $this->assertQueryIs("SELECT `notices_avis`.* ". "FROM `notices_avis` ". - "WHERE (ABON_OU_BIB='0') ". + "WHERE (flags=0) AND (ABON_OU_BIB='0') ". "ORDER BY `DATE_AVIS` DESC"); } @@ -662,7 +646,7 @@ class AvisLoaderGetAvisFromPreferencesTest extends AvisTestFindAllTestCase { $this->preferences['abon_ou_bib'] = '0'; $this->assertQueryIs("SELECT `notices_avis`.* ". "FROM `notices_avis` ". - "WHERE (ABON_OU_BIB='0') ". + "WHERE (flags=0) AND (ABON_OU_BIB='0') ". "AND ((STATUT=1 OR ABON_OU_BIB=1)) ". "ORDER BY `DATE_AVIS` DESC"); } @@ -672,7 +656,7 @@ class AvisLoaderGetAvisFromPreferencesTest extends AvisTestFindAllTestCase { $this->preferences['abon_ou_bib'] = '1'; $this->assertQueryIs("SELECT `notices_avis`.* ". "FROM `notices_avis` ". - "WHERE (ABON_OU_BIB='1') ". + "WHERE (flags=0) AND (ABON_OU_BIB='1') ". "ORDER BY `DATE_AVIS` DESC"); } @@ -682,7 +666,7 @@ class AvisLoaderGetAvisFromPreferencesTest extends AvisTestFindAllTestCase { $this->preferences['abon_ou_bib'] = '1'; $this->assertQueryIs("SELECT `notices_avis`.* ". "FROM `notices_avis` ". - "WHERE (ABON_OU_BIB='1') ". + "WHERE (flags=0) AND (ABON_OU_BIB='1') ". "AND ((STATUT=1 OR ABON_OU_BIB=0)) ". "ORDER BY `DATE_AVIS` DESC"); } @@ -811,7 +795,6 @@ class AvisVisibilityTest extends ModelTestCase { } - class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase { public function setUp() { parent::setUp(); @@ -864,9 +847,11 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase { ->whenCalled('findAllBy') ->with(['order' => 'DATE_AVIS DESC', 'clef_oeuvre' => ['POTTER'], + 'flags' => '0', 'where' => '(STATUT=1 OR ABON_OU_BIB=1) AND (STATUT=1 OR ABON_OU_BIB=0)']) ->answers([$this->_avis_bib_moderated, $this->_avis_abon_moderated]); + $this->assertEquals([$this->_avis_bib_moderated, $this->_avis_abon_moderated], Class_AvisNotice::getAvisFromPreferences(['id_panier' => 1])); } @@ -879,6 +864,7 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase { ->with(['order' => 'DATE_AVIS DESC', 'clef_oeuvre' => ['POTTER'], 'ABON_OU_BIB' => 0, + 'flags' => 0, 'where' => '(STATUT=1 OR ABON_OU_BIB=1) AND (STATUT=1 OR ABON_OU_BIB=0)']) ->answers([$this->_avis_abon_moderated]); @@ -894,6 +880,7 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase { ->with(['order' => 'DATE_AVIS DESC', 'clef_oeuvre' => ['POTTER'], 'ABON_OU_BIB' => 1, + 'flags' => 0, 'where' => '(STATUT=1 OR ABON_OU_BIB=1) AND (STATUT=1 OR ABON_OU_BIB=0)']) ->answers([$this->_avis_bib_moderated]); @@ -911,6 +898,7 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase { ->with(['order' => 'DATE_AVIS DESC', 'clef_oeuvre' => ['POTTER'], 'ABON_OU_BIB' => 0, + 'flags' => 0, 'where' => '(STATUT=1 OR ABON_OU_BIB=0)']) ->answers([$this->_avis_abon_moderated, $this->_avis_abon_not_moderated]); @@ -928,6 +916,7 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase { ->whenCalled('findAllBy') ->with(['order' => 'DATE_AVIS DESC', 'clef_oeuvre' => ['POTTER'], + 'flags' => 0, 'where' => '(STATUT=1 OR ABON_OU_BIB=0)']) ->answers([$this->_avis_bib_moderated, $this->_avis_abon_moderated, $this->_avis_abon_not_moderated]); @@ -947,6 +936,7 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase { ->whenCalled('findAllBy') ->with(['order' => 'DATE_AVIS DESC', 'clef_oeuvre' => ['POTTER'], + 'flags' => 0, 'where' => '(STATUT=1 OR ABON_OU_BIB=1)']) ->answers([$this->_avis_bib_moderated, $this->_avis_bib_not_moderated, $this->_avis_abon_moderated]); @@ -970,6 +960,7 @@ class AvisNoticeAvisFromPreferencesTest extends Storm_Test_ModelTestCase { Storm_Test_ObjectWrapper::onLoaderOfModel('Class_AvisNotice') ->whenCalled('findAllBy') ->with(['order' => 'DATE_AVIS DESC', + 'flags' => 0, 'id_notice' => -1]) ->answers([$this->_avis_bib_moderated, $this->_avis_bib_not_moderated, $this->_avis_abon_moderated]); diff --git a/tests/library/Class/Cosmogramme/Integration/PhaseReviewsTest.php b/tests/library/Class/Cosmogramme/Integration/PhaseReviewsTest.php new file mode 100644 index 0000000000000000000000000000000000000000..ce21f084dc5f5cf0698a580ecf92ba759b41476b --- /dev/null +++ b/tests/library/Class/Cosmogramme/Integration/PhaseReviewsTest.php @@ -0,0 +1,113 @@ +<?php +/** + * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH 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). + * + * BOKEH 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 BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +abstract class PhaseReviewsTestCase extends Class_Cosmogramme_Integration_PhaseTestCase { + public function setUp() { + parent::setUp(); + + $this->_phase = $this->_buildPhase('Reviews') + ->noDbReset() + ->run(); + } +} + + + +class PhaseReviewsBadPreviousPhaseTest extends PhaseReviewsTestCase { + protected function _getPreviousPhase() { + return new Class_Cosmogramme_Integration_Phase(6); + } + + + /** @test */ + public function shouldNotChangePhase() { + $this->assertTrue($this->_phase->isId(6)); + } +} + + + +class PhaseReviewsExpectedPreviousPhaseTest extends PhaseReviewsTestCase { + protected function _getPreviousPhase() { + return (new Class_Cosmogramme_Integration_Phase(7.5)) + ->beCron(); + } + + + protected function _prepareFixtures() { + $this->fixture('Class_AdminVar', + ['id' => 'AVIS_MIN_SAISIE', + 'valeur' => 0]); + $this->fixture('Class_AdminVar', + ['id' => 'AVIS_MAX_SAISIE', + 'valeur' => 1000]); + + $this->millenium = $this->fixture('Class_Notice', ['id' => 816, + 'titre_principal' => 'Millenium', + 'clef_alpha' => 'MILLENIUM', + 'auteur_principal' => 'Stieg Larsson', + 'url_vignette' => '', + 'url_image' => '' + ] + ); + + + $this->avis_millenium = $this->fixture('Class_AvisNotice', ['id' => 13, + 'entete' => "J'adore", + 'avis' => '<div><ul><li>Suspense Intense !</li><li>Suspense Intense !</li></ul></div>', + 'note' => 5, + 'date_avis' => '2011-03-18 13:00:00', + + 'statut' => 0, + 'abon_ou_bib'=>1 , + 'notices' => [] ]); + + + $this + ->onLoaderOfModel('Class_AvisNotice') + ->whenCalled('findAllAfter') + ->answers([$this->avis_millenium]); + } + + + /** @test */ + public function shouldChangePhase() { + $this->assertTrue($this->_phase->isId(7.5)); + } + + + /** @test */ + public function logShouldContainsPhaseLabel() { + $this->assertLogContains('Tous les avis ont été mis à jour'); + } + + + /** @test */ + public function logShouldContainsProcessedRecordCount() { + $this->assertLogContains('1 avis traités'); + } + +/** @test */ + public function noticeMilleniumShouldBeAttached() { + $this->assertEquals(816,Class_AvisNotice::find(13)->getIdNotice()); + } +}