Skip to content
Snippets Groups Projects
Commit 0857c672 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

Merge branch 'hotline#33429_lille_metro_pb_integration_cosmogramme' into 'hotline-master'

Hotline#33429 lille metro pb integration cosmogramme

See merge request !1302
parents 3c5b2b38 7bbfdbc9
6 merge requests!1553Master,!1502Master,!1501Stable,!1312Master,!1304Master,!1303Hotline master
- ticket #33429 : Cosmogramme : correction de la génération de vignettes des pseudo-notices dans le contexte de l'intégration automatique
\ No newline at end of file
......@@ -137,12 +137,14 @@ class Class_Profil extends Storm_Model_Abstract {
* @return Class_Profil
*/
public static function getCurrentProfil() {
if (!isset(self::$_current_profil)) {
if (!$id_profil = Zend_Registry::get('session')->id_profil)
$id_profil = 1;
self::$_current_profil = self::getLoader()->find($id_profil);
}
return self::$_current_profil;
if (isset(self::$_current_profil))
return self::$_current_profil;
if (!Zend_Registry::isRegistered('session')
|| (!$id_profil = Zend_Registry::get('session')->id_profil))
$id_profil = 1;
return self::$_current_profil = self::getLoader()->find($id_profil);
}
......
......@@ -20,6 +20,8 @@
*/
class ProfilVideTest extends ModelTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setup();
$this->profil_vide = new Class_Profil();
......@@ -58,7 +60,7 @@ class ProfilVideTest extends ModelTestCase {
public function profilZonesTitreShouldReturn200_E_H_I() {
$this->assertEquals(
['200$e', '200$h', '200$i'],
Class_Profil::getCurrentProfil()->getZonesTitre());
$this->profil_vide->getZonesTitre());
}
......@@ -71,6 +73,8 @@ class ProfilVideTest extends ModelTestCase {
class ProfilJeunesseAstrolabeTest extends ModelTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
$this->fixture('Class_AdminVar', ['clef' => 'NOM_DOMAINE',
'id' => 'NOM_DOMAINE',
......@@ -81,77 +85,65 @@ class ProfilJeunesseAstrolabeTest extends ModelTestCase {
'preferences' => []]],
'options' => []];
$this->profil_astro = Class_Profil::getLoader()
->newInstanceWithId(7)
->setIdSite(12)
->setLibelle("Jeunesse")
->setSkin('astrolabe')
->setCfgMenus(array())
->setHeaderCss('afi-opac3/userfiles/jeunesse.css')
->setCfgAccueil($cfg_accueil);
$this->profil_astro = $this->fixture('Class_Profil',
['id' => 7,
'id_site' => 12,
'libelle' => 'Jeunesse',
'skin' => 'astrolabe',
'cfg_menus' => [],
'header_css' => 'afi-opac3/userfiles/jeunesse.css',
'cfg_accueil' => $cfg_accueil]);
$this->bib_melun = Class_Bib::getLoader()
->newInstanceWithId(12)
->setLibelle('Melun');
$this->bib_melun = $this->fixture('Class_Bib',
['id' => 12,
'libelle' => 'Melun']);
$this->onLoaderOfModel('Class_Profil')
->whenCalled('findAllBy')
->answers([]);
Storm_Test_ObjectWrapper
::onLoaderOfModel('Class_Profil')
->whenCalled('findAllBy')
->answers(array());
Class_Profil::setFileWriter(Storm_Test_ObjectWrapper::mock()->whenCalled('fileExists')->answers(true));
Class_Profil::setFileWriter($this->mock()->whenCalled('fileExists')->answers(true));
}
/** @test */
public function profilUrlShouldReturnBokehDotOrg() {
$this->assertEquals('http://bokeh.org/index/index?id_profil=7', Class_Profil::find(7)->getUrl());
$this->assertEquals('http://bokeh.org/index/index?id_profil=7',
Class_Profil::find(7)->getUrl());
}
/** @test */
public function getCfgMenuAsArrayShouldReturnDefaultMenus() {
$this->assertEquals(array(
'H' => array(
"libelle" => "Menu horizontal",
"picto" => "vide.gif",
'menus' => array()),
'V' => array(
"libelle" => "Menu vertical",
"picto" => "vide.gif",
'menus' => array())),
$this->assertEquals(['H' => ["libelle" => "Menu horizontal",
"picto" => "vide.gif",
'menus' => []],
'V' => ["libelle" => "Menu vertical",
"picto" => "vide.gif",
'menus' => []]],
$this->profil_astro->getCfgMenusAsArray());
}
/** @test */
public function shouldAddMenuHorizontalIfNotExists() {
$this->profil_astro->setCfgMenus( array(
'V' => array(
"libelle" => "Les news",
"picto" => "home.gif",
"menus" => array()),
'4' => array(
"libelle" => "Mon menu",
"picto" => "home.png",
"menus" => array())));
$this->assertEquals(array(
'H' => array(
"libelle" => "Menu horizontal",
"picto" => "vide.gif",
"menus" => array()),
'V' => array(
"libelle" => "Les news",
"picto" => "home.gif",
"menus" => array()),
'4' => array(
"libelle" => "Mon menu",
"picto" => "home.png",
"menus" => array())),
$this->profil_astro
->setCfgMenus(['V' => ["libelle" => "Les news",
"picto" => "home.gif",
"menus" => []],
'4' => ["libelle" => "Mon menu",
"picto" => "home.png",
"menus" => []]]);
$this->assertEquals(['H' => ["libelle" => "Menu horizontal",
"picto" => "vide.gif",
"menus" => []],
'V' => ["libelle" => "Les news",
"picto" => "home.gif",
"menus" => []],
'4' => ["libelle" => "Mon menu",
"picto" => "home.png",
"menus" => []]],
$this->profil_astro->getCfgMenusAsArray());
}
......@@ -165,7 +157,8 @@ class ProfilJeunesseAstrolabeTest extends ModelTestCase {
/** @test */
public function astroHeaderCssShouldBeJeunesse() {
$this->assertEquals('afi-opac3/userfiles/jeunesse.css', $this->profil_astro->getHeaderCss());
$this->assertEquals('afi-opac3/userfiles/jeunesse.css',
$this->profil_astro->getHeaderCss());
}
......@@ -232,7 +225,7 @@ class ProfilJeunesseAstrolabeTest extends ModelTestCase {
/** @test */
public function toArrayShouldContainsTitreSiteMediathequeAstrolabe() {
$attributes = $this->profil_astro->toArray();
$this->assertEquals("", $attributes['titre_site']);
$this->assertEquals('', $attributes['titre_site']);
}
......@@ -280,7 +273,7 @@ class ProfilJeunesseAstrolabeTest extends ModelTestCase {
/** @test */
public function updateAttributesWithBoiteLoginTrueShouldAddIt() {
$this->profil_astro->updateAttributes(array('boite_login_in_banniere' => true));
$this->profil_astro->updateAttributes(['boite_login_in_banniere' => true]);
$this->assertTrue($this->profil_astro->getBoiteLoginInBanniere());
}
......@@ -293,19 +286,14 @@ class ProfilJeunesseAstrolabeTest extends ModelTestCase {
/** @test */
public function getSubProfilsShouldReturnEmptyArray() {
$this->assertEquals(array(),
$this->profil_astro->getSubProfils());
return Class_Profil::getLoader();
$this->assertEquals([], $this->profil_astro->getSubProfils());
}
/**
* @depends getSubProfilsShouldReturnEmptyArray
* @test
*/
public function profilLoaderShouldHaveFindAllByCalledWithParentIdOfAstrolabe($loader) {
$param = $loader->getFirstAttributeForLastCallOn('findAllBy');
/** @test */
public function profilLoaderShouldHaveFindAllByCalledWithParentIdOfAstrolabe() {
$this->profil_astro->getSubProfils();
$param = Class_Profil::getFirstAttributeForLastCallOn('findAllBy');
$this->assertEquals('parent_profil', $param['role']);
$this->assertEquals($this->profil_astro->toArray(),
......@@ -323,7 +311,8 @@ class ProfilJeunesseAstrolabeTest extends ModelTestCase {
class PageBdAstrolabeTest extends Storm_Test_ModelTestCase {
class PageBdAstrolabeTest extends ModelTestCase {
protected $_storm_default_to_volatile = true;
protected $page_bd;
protected $profil_astro;
protected $bib_melun;
......@@ -340,38 +329,33 @@ class PageBdAstrolabeTest extends Storm_Test_ModelTestCase {
'preferences' => ['titre'=>'Connection']]],
'options' => []];
$this->profil_astro = Class_Profil::getLoader()
->newInstanceWithId(7)
->setIdSite(12)
->setLibelle("Jeunesse")
->setSkin('astrolabe')
->setCfgMenus(array())
->setHeaderCss('afi-opac3/userfiles/jeunesse.css')
->setCfgAccueil($cfg_accueil);
$this->bib_melun = Class_Bib::getLoader()
->newInstanceWithId(12)
->setLibelle('Melun');
Storm_Test_ObjectWrapper
::onLoaderOfModel('Class_Profil')
->whenCalled('findAllBy')
->answers(array());
Class_Profil::setFileWriter(
Storm_Test_ObjectWrapper::mock()
->whenCalled('fileExists')
->answers(true));
$this->page_bd = Class_Profil::getLoader()
->newInstanceWithId(6,
['parent_id' => $this->profil_astro->getId(),
'id_site' => 12,
'libelle' => 'Bdd',
'cfg_menus' => [],
'cfg_accueil' => [],
'page_css' => 'afi-opac3/userfiles/bd_jeunesse.css']);
$this->profil_astro = $this->fixture('Class_Profil',
['id' => 7,
'id_site' => 12,
'libelle' => 'Jeunesse',
'skin' => 'astrolabe',
'cfg_menus' => [],
'header_css' => 'afi-opac3/userfiles/jeunesse.css',
'cfg_accueil' => $cfg_accueil]);
$this->bib_melun = $this->fixture('Class_Bib',
['id' => 12,
'libelle' => 'Melun']);
$this->onLoaderOfModel('Class_Profil')
->whenCalled('findAllBy')
->answers([]);
Class_Profil::setFileWriter($this->mock()->whenCalled('fileExists')->answers(true));
$this->page_bd = $this->fixture('Class_Profil',
['id' => 6,
'parent_id' => $this->profil_astro->getId(),
'id_site' => 12,
'libelle' => 'Bdd',
'cfg_menus' => [],
'cfg_accueil' => [],
'page_css' => 'afi-opac3/userfiles/bd_jeunesse.css',]);
$this->profil_astro->setSubProfils([$this->page_bd]);
}
......@@ -1601,8 +1585,4 @@ class ProfilIsPortalTest extends Storm_Test_ModelTestCase {
public function profilWithIdSevenStringShouldNotBePortal() {
$this->assertFalse($this->fixture('Class_Profil', ['id' => '7'])->isPortail());
}
}
?>
\ No newline at end of file
}
\ No newline at end of file
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