Skip to content
Snippets Groups Projects
Commit a73413c6 authored by Julian Maurice's avatar Julian Maurice
Browse files

dev #14409 filters in calendar box

cms calendar test refactoring
parent 21485caa
Branches
Tags
2 merge requests!529Hotline 6.56,!407Dev/14409 filters in calendar box
......@@ -18,52 +18,47 @@
* 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';
class CalendarCmsActionTest extends AbstractControllerTestCase {
protected $_article_loader;
protected $_nanook2, $_opac4;
abstract class CmsControllerCalendarActionTestCase extends AbstractControllerTestCase {
protected
$_nanook2;
public function setUp() {
parent::setUp();
$this->cfg_accueil =
array('modules' => array('1' => array('division' => '1',
'type_module' => 'CALENDAR',
'preferences' => array('titre' => 'Rendez-vous',
'rss_avis' => false,
'id_categorie' => '12-2',
'display_cat_select' => true,
'display_event_info' => 'none'))),
'options' => array());
$this->profil_rdv = Class_Profil::getLoader()->newInstanceWithId(3)
->setBrowser('opac')
->setLibelle('Rendez-vous')
->setCfgAccueil($this->cfg_accueil);
$_SESSION["CALENDAR"] = array('DATE' => '',
'HTML' => array(''));
Class_AdminVar::getLoader()->newInstanceWithId('CACHE_ACTIF')->setValeur('1');
$this->_nanook2 = Class_Article::getLoader()
->newInstanceWithId(4)
->setTitre('Nanook 2 en prod !')
->setEventsDebut('2011-02-17')
->setEventsFin('2011-02-22');
$this->_opac4 = Class_Article::getLoader()
->newInstanceWithId(4)
->setTitre('OPAC 4 en prod !')
->setEventsDebut('2011-02-17')
->setEventsFin('2011-02-22');
$this->_article_loader = Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Article')
['modules' =>
[ '1' => [
'division' => '1',
'type_module' => 'CALENDAR',
'preferences' => [
'titre' => 'Rendez-vous',
'rss_avis' => false,
'id_categorie' => '12-2',
'display_cat_select' => true,
'enabled_filters' => 'month;place;custom_field_2',
'display_event_info' => 'none']]],
'options' => []];
$this->fixture('Class_Profil',
['id' => 3,
'browser' => 'opac',
'libelle' => 'Rendez-vous',
'cfg_accueil' => $this->cfg_accueil]);
Class_AdminVar::newInstanceWithId('CACHE_ACTIF',
['valeur' => '1']);
$this->_nanook2 = $this->fixture('Class_Article',
['id' => 4,
'titre' => 'Nanook 2 en prod !',
'contenu' => 'youpi !',
'events_debut' => '2011-02-17',
'events_fin' => '2011-02-22']);
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Article')
->whenCalled('getArticlesByPreferences')
->answers(array($this->_nanook2))->getWrapper();
->answers([$this->nanook2]);
}
......@@ -71,54 +66,106 @@ class CalendarCmsActionTest extends AbstractControllerTestCase {
Class_AdminVar::getLoader()->find('CACHE_ACTIF')->setValeur('0');
parent::tearDown();
}
}
class CmsControllerCalendarActionCacheTest extends CmsControllerCalendarActionTestCase {
public function setUp() {
parent::setUp();
$cache = Storm_Test_ObjectWrapper::mock();
Storm_Cache::setDefaultZendCache($cache);
$module_cal = new ZendAfi_View_Helper_Accueil_Calendar(1, $this->cfg_accueil['modules']['1']);
$module_cal->setView(new ZendAfi_Controller_Action_Helper_View());
}
/**
* Test non-regression vu sur Bucarest (prenait le layout normal au lieu du layout iframe)
* @test
*/
function calendarShouldNotBeInAnIframeEventWithCacheActive() {
$cache = Storm_Test_ObjectWrapper::mock();
Storm_Cache::setDefaultZendCache($cache);
$module_cal = new ZendAfi_View_Helper_Accueil_Calendar(1, $this->cfg_accueil['modules']['1']);
$module_cal->setView(new ZendAfi_Controller_Action_Helper_View());
$this->dispatch('/cms/calendar/id_profil/3/id_module/1/render/ajax');
// ça plantait lors de la réutilisation du cache, donc 2 dispatchs
$this->bootstrap();
$this->dispatch('/cms/calendar/id_profil/3/id_module/1/render/ajax');
$this->assertNotXPath('//div[@id="site_web_wrapper"]');
}
}
class CmsControllerCalendarActionLanguageEnTest extends CmsControllerCalendarActionTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/cms/calendar/id_profil/3/id_module/1/select_id_categorie/2/date/2011-02/language/en/render/ajax');
}
/** @test */
function withLocaleEnMonthShouldBeFebruary() {
$this->dispatch('/cms/calendar/id_profil/3/id_module/1/select_id_categorie/2/date/2011-02/language/en/render/ajax');
$this->assertXPathContentContains('//td[@class="calendar_title_month"]/a', "february", $this->_response->getBody());
}
/** @test **/
function calendarShouldContains3AwithClassCalendarTitleMonthClickable() {
$this->dispatch('/cms/calendar/id_profil/3/id_module/1/select_id_categorie/2/date/2011-02/language/en/render/ajax');
$this->assertXPathCount('//a[@class="calendar_title_month_clickable"]',3,$this->_response->getBody());
$this->assertXPathCount('//a[@class="calendar_title_month_clickable"]',3);
}
}
class CmsControllerCalendarActionWithFiltersTest extends CmsControllerCalendarActionTestCase {
protected $_opac4;
public function setupCustomFields() {
Class_CustomField_Meta::beVolatile();
$theme = $this->fixture('Class_CustomField',
['id' => 2,
'priority' => 3,
'label' => 'Theme',
'field_type' => Class_CustomField_Meta::SELECT,
'options_list' => 'sigb;opac',
'model' => 'Article']);
$this->fixture('Class_CustomField_Value',
['id' => 5,
'custom_field_id' => $theme->getId(),
'model' => $this->_nanook2,
'value' => 'sigb']);
$this->fixture('Class_CustomField_Value',
['id' => 2,
'custom_field_id' => $theme->getId(),
'model' => $this->_opac4,
'value' => 'opac']);
}
public function setUp() {
parent::setUp();
$this->_opac4 = $this->fixture('Class_Article',
['id' => 5,
'titre' => 'OPAC 4 en prod !',
'contenu' => 'youpi !',
'events_debut' => '2011-02-17',
'events_fin' => '2011-02-22']);
$this->setupCustomFields();
/** @test **/
function calendarWithCustomFieldFiltersShould() {
$common_preferences = [
'display_order' => 'EventDebut',
'id_categorie' => '',
'events_only' => true,
'id_bib' => 0,
'custom_fields' => [
2 => 'music',
],
'published' => false,
];
$this->_article_loader
'display_order' => 'EventDebut',
'id_categorie' => '',
'events_only' => true,
'id_bib' => 0,
'custom_fields' => [
2 => 'music',
],
'published' => false];
Class_Article::getLoader()
->whenCalled('getArticlesByPreferences')
->with(array_merge($common_preferences, ['event_date' => '2014-08']))
->answers([$this->_opac4])
......@@ -132,9 +179,13 @@ class CalendarCmsActionTest extends AbstractControllerTestCase {
->beStrict();
$this->dispatch('/cms/calendar/date/2014-08/custom_field_2/music', true);
}
/** @test **/
function calendarWithCustomFieldFiltersShouldBuildPreferencesForGetArticlesByPreferences() {
$this->assertXPathContentContains('//a[@class="calendar_event_title"]',
'OPAC 4 en prod !',
$this->_response->getBody());
'OPAC 4 en prod !');
}
}
......
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