diff --git a/library/Class/Agenda/SQY.php b/library/Class/Agenda/SQY.php index dbf57bb50a7f21c3560dd1fda36a10f8e3a4ef52..cef5a7ac03c9d1af2b4c0ffebd6d9bdd298785d7 100644 --- a/library/Class/Agenda/SQY.php +++ b/library/Class/Agenda/SQY.php @@ -45,11 +45,10 @@ Trait Trait_Agenda_SQY_ItemWrapper { } public function __call($method, $args) { - if (!isset(static::$_method_map[$method])) - return null; - - return call_user_func_array([$this->_wrapped_instance, static::$_method_map[$method]], - $args); + return isset(static::$_method_map[$method]) + ? call_user_func_array([$this->_wrapped_instance, static::$_method_map[$method]], + $args) + : null; } } @@ -58,7 +57,28 @@ class Class_Agenda_SQY_EventWrapper { use Trait_Agenda_SQY_ItemWrapper; protected static $_item_class = 'Class_Article'; - protected static $_method_map = []; + protected static $_method_map = ['setTitle' => 'setTitre', + 'getTitre' => 'getTitre', + 'setAbstract' => 'setDescription', + 'getDescription' => 'getDescription', + 'setDescription' => 'setContenu', + 'getContenu' => 'getContenu', + 'getEventsDebut' => 'getEventsDebut', + 'getEventsFin' => 'getEventsFin',]; + + + public function formatDateForArticle($date) { + return implode('-', array_reverse(explode('/', $date))); + } + + public function setDateStart($date) { + $this->_wrapped_instance->setEventsDebut($this->formatDateForArticle($date)); + } + + + public function setDateEnd($date) { + $this->_wrapped_instance->setEventsFin($this->formatDateForArticle($date)); + } } @@ -162,16 +182,30 @@ class Class_Agenda_SQY { public function endTitle($data) { $this->_item->setTitle($data); } - public function endZip($data) { $this->_item->setZip($data); } - public function endCity($data) { $this->_item->setCity($data); } + + public function endAbstract($data) { + $this->_item->setAbstract($data); + } + + public function endDescription($data) { + $this->_item->setDescription($data); + } + + public function endDate_Start($data) { + $this->_item->setDateStart($data); + } + + public function endDate_End($data) { + $this->_item->setDateEnd($data); + } } ?> \ No newline at end of file diff --git a/tests/library/Class/AgendaSQYImportTest.php b/tests/library/Class/AgendaSQYImportTest.php index 5e4978c1174de4caa04ad90e004be721dcad866d..43edeb8c85edb375a61757a194e57d243db65f99 100644 --- a/tests/library/Class/AgendaSQYImportTest.php +++ b/tests/library/Class/AgendaSQYImportTest.php @@ -93,6 +93,53 @@ class AgendaSQYImportTest extends Storm_Test_ModelTestCase { public function firstLocationPaysShouldBeFrance($musee) { $this->assertEquals('France', $musee->getPays()); } + + + /** @test */ + public function firstEventTitreShouldBeRevonsLaVille() { + $event_revons = $this->_events[0]; + $this->assertEquals('"Rêvons la ville"', $event_revons->getTitre()); + return $event_revons; + } + + + /** + * @test + * @depends firstEventTitreShouldBeRevonsLaVille + */ + public function firstEventDescriptionShouldContainsLaNouvelleExposition($event_revons) { + $this->assertContains('la nouvelle exposition du Musée', $event_revons->getDescription()); + } + + + /** + * @test + * @depends firstEventTitreShouldBeRevonsLaVille + */ + public function firstEventContenuShouldContainsDesActeursDeSaintQuentin($event_revons) { + $this->assertContains('<p>Des acteurs de Saint-Quentin-en-Yvelines', + $event_revons->getContenu()); + } + + + /** + * @test + * @depends firstEventTitreShouldBeRevonsLaVille + */ + public function firstEventDebutShouldBe2012Dash05Dash16($event_revons) { + $this->assertEquals('2012-05-16', + $event_revons->getEventsDebut()); + } + + + /** + * @test + * @depends firstEventTitreShouldBeRevonsLaVille + */ + public function firstEventFinShouldBe2013Dash03Dash16($event_revons) { + $this->assertEquals('2013-03-16', + $event_revons->getEventsFin()); + } }