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 @@ ...@@ -18,52 +18,47 @@
* along with AFI-OPAC 2.0; if not, write to the Free Software * 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
*/ */
require_once 'AbstractControllerTestCase.php'; abstract class CmsControllerCalendarActionTestCase extends AbstractControllerTestCase {
protected
class CalendarCmsActionTest extends AbstractControllerTestCase { $_nanook2;
protected $_article_loader;
protected $_nanook2, $_opac4;
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
$this->cfg_accueil = $this->cfg_accueil =
array('modules' => array('1' => array('division' => '1', ['modules' =>
'type_module' => 'CALENDAR', [ '1' => [
'preferences' => array('titre' => 'Rendez-vous', 'division' => '1',
'rss_avis' => false, 'type_module' => 'CALENDAR',
'id_categorie' => '12-2', 'preferences' => [
'display_cat_select' => true, 'titre' => 'Rendez-vous',
'display_event_info' => 'none'))), 'rss_avis' => false,
'options' => array()); 'id_categorie' => '12-2',
'display_cat_select' => true,
'enabled_filters' => 'month;place;custom_field_2',
$this->profil_rdv = Class_Profil::getLoader()->newInstanceWithId(3) 'display_event_info' => 'none']]],
->setBrowser('opac') 'options' => []];
->setLibelle('Rendez-vous')
->setCfgAccueil($this->cfg_accueil);
$this->fixture('Class_Profil',
$_SESSION["CALENDAR"] = array('DATE' => '', ['id' => 3,
'HTML' => array('')); 'browser' => 'opac',
'libelle' => 'Rendez-vous',
Class_AdminVar::getLoader()->newInstanceWithId('CACHE_ACTIF')->setValeur('1'); 'cfg_accueil' => $this->cfg_accueil]);
$this->_nanook2 = Class_Article::getLoader() Class_AdminVar::newInstanceWithId('CACHE_ACTIF',
->newInstanceWithId(4) ['valeur' => '1']);
->setTitre('Nanook 2 en prod !')
->setEventsDebut('2011-02-17') $this->_nanook2 = $this->fixture('Class_Article',
->setEventsFin('2011-02-22'); ['id' => 4,
'titre' => 'Nanook 2 en prod !',
'contenu' => 'youpi !',
$this->_opac4 = Class_Article::getLoader() 'events_debut' => '2011-02-17',
->newInstanceWithId(4) 'events_fin' => '2011-02-22']);
->setTitre('OPAC 4 en prod !')
->setEventsDebut('2011-02-17') Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Article')
->setEventsFin('2011-02-22');
$this->_article_loader = Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Article')
->whenCalled('getArticlesByPreferences') ->whenCalled('getArticlesByPreferences')
->answers(array($this->_nanook2))->getWrapper(); ->answers([$this->nanook2]);
} }
...@@ -71,54 +66,106 @@ class CalendarCmsActionTest extends AbstractControllerTestCase { ...@@ -71,54 +66,106 @@ class CalendarCmsActionTest extends AbstractControllerTestCase {
Class_AdminVar::getLoader()->find('CACHE_ACTIF')->setValeur('0'); Class_AdminVar::getLoader()->find('CACHE_ACTIF')->setValeur('0');
parent::tearDown(); 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 non-regression vu sur Bucarest (prenait le layout normal au lieu du layout iframe)
* @test * @test
*/ */
function calendarShouldNotBeInAnIframeEventWithCacheActive() { 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'); $this->dispatch('/cms/calendar/id_profil/3/id_module/1/render/ajax');
// ça plantait lors de la réutilisation du cache, donc 2 dispatchs // ça plantait lors de la réutilisation du cache, donc 2 dispatchs
$this->bootstrap(); $this->bootstrap();
$this->dispatch('/cms/calendar/id_profil/3/id_module/1/render/ajax'); $this->dispatch('/cms/calendar/id_profil/3/id_module/1/render/ajax');
$this->assertNotXPath('//div[@id="site_web_wrapper"]'); $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 */ /** @test */
function withLocaleEnMonthShouldBeFebruary() { 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()); $this->assertXPathContentContains('//td[@class="calendar_title_month"]/a', "february", $this->_response->getBody());
} }
/** @test **/ /** @test **/
function calendarShouldContains3AwithClassCalendarTitleMonthClickable() { 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->assertXPathCount('//a[@class="calendar_title_month_clickable"]',3,$this->_response->getBody());
} }
}
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 = [ $common_preferences = [
'display_order' => 'EventDebut', 'display_order' => 'EventDebut',
'id_categorie' => '', 'id_categorie' => '',
'events_only' => true, 'events_only' => true,
'id_bib' => 0, 'id_bib' => 0,
'custom_fields' => [ 'custom_fields' => [
2 => 'music', 2 => 'music',
], ],
'published' => false, 'published' => false];
];
Class_Article::getLoader()
$this->_article_loader
->whenCalled('getArticlesByPreferences') ->whenCalled('getArticlesByPreferences')
->with(array_merge($common_preferences, ['event_date' => '2014-08'])) ->with(array_merge($common_preferences, ['event_date' => '2014-08']))
->answers([$this->_opac4]) ->answers([$this->_opac4])
...@@ -132,9 +179,13 @@ class CalendarCmsActionTest extends AbstractControllerTestCase { ...@@ -132,9 +179,13 @@ class CalendarCmsActionTest extends AbstractControllerTestCase {
->beStrict(); ->beStrict();
$this->dispatch('/cms/calendar/date/2014-08/custom_field_2/music', true); $this->dispatch('/cms/calendar/date/2014-08/custom_field_2/music', true);
}
/** @test **/
function calendarWithCustomFieldFiltersShouldBuildPreferencesForGetArticlesByPreferences() {
$this->assertXPathContentContains('//a[@class="calendar_event_title"]', $this->assertXPathContentContains('//a[@class="calendar_event_title"]',
'OPAC 4 en prod !', 'OPAC 4 en prod !');
$this->_response->getBody());
} }
} }
......
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