Skip to content
Snippets Groups Projects
Commit be8df101 authored by Laurent's avatar Laurent
Browse files

hotline #16319 homepage module BibNumerique display albums using title order

parent 2b972bc8
Branches
Tags
2 merge requests!529Hotline 6.56,!408Hotline 16358 fix update notice cosmogramme
- ticket #16319: la boîte bibliothèque numérique affiche les albums dans l'ordre des titres
20/09/2014 - v6.52.5
- ticket #14149: Cosmogramme / Aloes: ajout d'une option pour ne pas envoyer le code annexe pour la réservation des exemplaires. Ce qui permet de contourner le bug du web service Aloes qui gère mal l'option site de retrait = site de l'abonné.
......
......@@ -16,15 +16,15 @@
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class AlbumCategorieLoader extends Storm_Model_Loader {
/**
* @return array
/**
* @return array
*/
public function getCollections() {
return $this->findAllBy(array('parent_id' => 0,
return $this->findAllBy(array('parent_id' => 0,
'order' => 'libelle'));
}
......@@ -75,6 +75,7 @@ class Class_AlbumCategorie extends Storm_Model_Abstract {
'albums' => array('model' => 'Class_Album',
'role' => 'categorie',
'order' => 'libelle',
'dependents' => 'delete'));
protected $_default_attribute_values = array('parent_id' => 0);
......@@ -98,7 +99,7 @@ class Class_AlbumCategorie extends Storm_Model_Abstract {
public function getChildrenCount() {
return $this->numberOfAlbums();
}
public function hasNoChild() {
return !$this->hasChildren();
......@@ -111,7 +112,7 @@ class Class_AlbumCategorie extends Storm_Model_Abstract {
public function isNew() {
return parent::isNew() || 0 == $this->getId();
}
/**
* @param array $datas
......
......@@ -16,46 +16,46 @@
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class AlbumCategorieRootTest extends ModelTestCase {
public function setUp() {
$this->root = new Class_AlbumCategorie;
$this->root
->setId(0)
->setLibelle('ROOT')
->setSousCategories(array());
$this->cat_jeunesse = Class_AlbumCategorie::getLoader()
->newInstanceWithId(23)
->setLibelle('Jeunesse')
->setSousCategories(array())
->setParentCategorie($this->root);
$this->root->addSousCategorie($this->cat_jeunesse);
$this->cat_jeunesse = $this->fixture('Class_AlbumCategorie',
['id' => 23,
'libelle' => 'Jeunesse',
'sous_categories' => []]);
$this->album_tintin = $this->fixture('Class_Album',
['id' => 5,
'titre' => 'Tintin',
'categorie' => $this->cat_jeunesse]);
$this->album_lagaffe = $this->fixture('Class_Album',
['id' => 9,
'titre' => 'Gaston Lagaffe',
'categorie' => $this->cat_jeunesse]);
$this->album_tintin = Class_Album::getLoader()
->newInstanceWithId(5)
->setLibelle('Tintin')
->setCategorie($this->cat_jeunesse);
Class_AlbumCategorie::clearCache();
Class_Album::clearCache();
$this->cat_jeunesse = Class_AlbumCategorie::find(23);
$this->album_lagaffe = Class_Album::getLoader()
->newInstanceWithId(9)
->setLibelle('Gaston Lagaffe')
->setCategorie($this->cat_jeunesse);
$this->cat_jeunesse
->setAlbums(array($this->album_tintin,
$this->album_lagaffe));
$this->root = $this->fixture('Class_AlbumCategorie',
['id' => 0,
'libelle' => 'ROOT']);
$this->root->addSousCategorie($this->cat_jeunesse);
$this->cat_jeunesse->setParentCategorie($this->root);
}
/** @test */
public function shouldNotHaveParentCategory() {
$this->assertFalse($this->root->hasParentCategorie());
}
/** @test */
public function libelleShouldBeRoot() {
......@@ -65,33 +65,37 @@ class AlbumCategorieRootTest extends ModelTestCase {
/** @test */
public function getSousCategoriesShouldReturnAnArrayWithAlbumJeunesse() {
$this->assertEquals(array($this->cat_jeunesse), $this->root->getSousCategories());
$this->assertEquals(['Jeunesse'],
array_map(function($c) {return $c->getLibelle();},
$this->root->getSousCategories()));
}
/** @test */
public function catJeunesseGetAlbumsShouldReturnLagaffeAndTintin() {
$this->assertEquals(array($this->album_tintin, $this->album_lagaffe),
$this->cat_jeunesse->getAlbums());
$this->assertEquals(['Gaston Lagaffe', 'Tintin'],
array_map(function($a) {return $a->getTitre();},
$this->cat_jeunesse->getAlbums()));
}
/** @test */
public function albumTintinCategorieShouldBeCatJeunesse() {
$this->assertEquals($this->cat_jeunesse->getId(),
$this->assertEquals($this->cat_jeunesse->getId(),
$this->album_tintin->getCategorie()->getId());
}
/** @test */
public function albumTintinHierarchyShouldIncludeCatJeunesseAndRoot() {
$this->assertEquals(array($this->cat_jeunesse, $this->root),
$this->album_tintin->getHierarchy());
$this->assertEquals(['Jeunesse', 'ROOT'],
array_map(function($c) {return $c->getLibelle();},
Class_Album::find(5)->getHierarchy()));
}
/** @test */
public function catJeunesseHierarchyShouldIncludeRoot() {
$this->assertEquals(array($this->root),
$this->assertEquals(array($this->root),
$this->cat_jeunesse->getHierarchy());
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment