diff --git a/tests/application/modules/admin/controllers/BibControllerTest.php b/tests/application/modules/admin/controllers/BibControllerTest.php index 75192b2ea8e00779510fefdb6842b2dbca04bd58..1b24c6c6d02bca902e573b760b996d351cc3c374 100644 --- a/tests/application/modules/admin/controllers/BibControllerTest.php +++ b/tests/application/modules/admin/controllers/BibControllerTest.php @@ -1981,4 +1981,15 @@ class BibControllerDeleteDefaultFiltersTest extends Admin_AbstractControllerTest public function openedShouldHaveBeenRemovedFromSettings() { $this->assertEmpty(Class_Profil::getCurrentProfil()->getLocalModuleAccueilConfig(1)['preferences']['default_filters']); } + + + /** @test */ + public function defaultFiltersContainsOpeningsOpened() { + $widget = (new Class_Systeme_Widget_Widget()) + ->setId(1) + ->setProfileId(Class_Profil::getCurrentProfil()->getId()) + ->load(); + + $this->assertEquals(['opening' => ['opened']], $widget->getdefault_filters()); + } } diff --git a/tests/application/modules/admin/controllers/WidgetControllerTest.php b/tests/application/modules/admin/controllers/WidgetControllerTest.php index a5db5a64ffaf91053733958d59f1618c9d1d0b68..a849f96d63ccd6e51915fcf09385c65266fbdcc9 100644 --- a/tests/application/modules/admin/controllers/WidgetControllerTest.php +++ b/tests/application/modules/admin/controllers/WidgetControllerTest.php @@ -2026,8 +2026,6 @@ class WidgetControllerLibrarySimpleDispatchTest extends WidgetControllerDispatch } - - class WidgetControllerAddFromTemplateActionLinkTest extends WidgetControllerWidgetConfigurationTestCase { public function setUp() { $this->_type_module = 'LOGIN'; @@ -2364,3 +2362,63 @@ class WidgetControllerUpdateStyleTest extends Admin_AbstractControllerTestCase { 'value: 80'); } } + + + + +class WidgetControllerLibraryPostDispatchFromCorruptedDataTest extends WidgetControllerWidgetConfigurationTestCase { + + public function setUp() { + $this->_type_module = 'LIBRARY'; + $this->_preferences = ['titre' => 'Médiathèque', + 'libraries' => '45', + 'default_filters' => 'Array', + 'filters' => '']; + parent::setup(); + $this->postDispatch('/admin/widget/edit-widget/id/6/id_profil/5', + ['titre' => 'Médiathèque', + 'libraries' => '45', + 'filters' => 'town']); + } + + + /** @test */ + public function defaultFiltersShouldBeEmpty() { + $widget = (new Class_Systeme_Widget_Widget()) + ->setId(6) + ->setProfileId(5) + ->load(); + + $this->assertEquals([], $widget->getdefault_filters()); + } +} + + + + +class WidgetControllerLibraryPostDispatchTest extends WidgetControllerWidgetConfigurationTestCase { + + public function setUp() { + $this->_type_module = 'LIBRARY'; + $this->_preferences = ['titre' => 'Médiathèque', + 'libraries' => '45', + 'default_filters' => ['town' => [1]], + 'filters' => '']; + parent::setup(); + $this->postDispatch('/admin/widget/edit-widget/id/6/id_profil/5', + ['titre' => 'Médiathèque', + 'libraries' => '45', + 'filters' => 'town']); + } + + + /** @test */ + public function defaultFiltersShouldContainsTown1() { + $widget = (new Class_Systeme_Widget_Widget()) + ->setId(6) + ->setProfileId(5) + ->load(); + + $this->assertEquals(['town' => [1]], $widget->getdefault_filters()); + } +} diff --git a/tests/application/modules/opac/controllers/BibControllerTest.php b/tests/application/modules/opac/controllers/BibControllerTest.php index c8592ad985cb6f8ecf6376a25c0c3bf02fdb2083..fdf9821bfa9f30c4b6392e009e3811a4ba4bf22b 100644 --- a/tests/application/modules/opac/controllers/BibControllerTest.php +++ b/tests/application/modules/opac/controllers/BibControllerTest.php @@ -2112,4 +2112,31 @@ class BibControllerMapActionWithNoLocationTest extends AbstractControllerTestCas public function leafletJsLibraryShouldNotBeInDom() { $this->assertNotXPath('//script[contains(@src, "leaflet.js")]', $this->_response->getBody()); } +} + + + + +class BibControllerWithDefaultFiltersCorruptedTest extends BibControllerWidgetPageTestCase { + protected $_bib_wrapper; + + public function setUp() { + parent::setUp(); + + Class_Profil::getCurrentProfil() + ->updateModuleConfigAccueil(1, [ + 'division' => '2', + 'type_module' => 'LIBRARY', + 'preferences' => array_merge($this->_preferences, + ['default_filters' => 'Array']) + ]); + + $this->dispatch('/opac/index/index', true); + } + + + /** @test */ + public function librariesShouldBePresent() { + $this->assertXPathContentContains('//h2' , 'Annecy', $this->_response->getBody()); + } } \ No newline at end of file