diff --git a/application/modules/admin/views/scripts/cms/newsform.phtml b/application/modules/admin/views/scripts/cms/newsform.phtml index 889934f5dbf514bce10127a11eb723343db82616..ba42fff5f6ba6c4095da47446984f9e39956f340 100644 --- a/application/modules/admin/views/scripts/cms/newsform.phtml +++ b/application/modules/admin/views/scripts/cms/newsform.phtml @@ -133,7 +133,7 @@ Class_ScriptLoader::getInstance() <tr> <td><?php echo $this->traduire('Lieu'); ?></td> <td><?php echo $this->formSelect('id_lieu', - null, + $this->article->getIdLieu(), null, $this->combo_lieu_options); ?></td> </tr> diff --git a/library/Class/Article.php b/library/Class/Article.php index 5b37a8d167775e3817446a2ad5322c5ded950828..52decd951cbcbf75e1d108eb731136028dc01e5d 100644 --- a/library/Class/Article.php +++ b/library/Class/Article.php @@ -387,33 +387,36 @@ class Class_Article extends Storm_Model_Abstract { protected $_table_name = 'cms_article'; protected $_table_primary = 'ID_ARTICLE'; - protected $_has_many = array('traductions' => array('model' => 'Class_Article', - 'role' => 'article_original', - 'dependents' => 'delete'), + protected $_has_many = ['traductions' => ['model' => 'Class_Article', + 'role' => 'article_original', + 'dependents' => 'delete'], - 'avis_users' => array('model' => 'Class_Avis', - 'role' => 'article', - 'dependents' => 'delete', - 'order' => 'date_avis desc')); + 'avis_users' => ['model' => 'Class_Avis', + 'role' => 'article', + 'dependents' => 'delete', + 'order' => 'date_avis desc']]; - protected $_belongs_to = array('categorie' => array('model' => 'Class_ArticleCategorie', - 'referenced_in' => 'id_cat'), + protected $_belongs_to = ['categorie' => ['model' => 'Class_ArticleCategorie', + 'referenced_in' => 'id_cat'], - 'article_original' => array('model' => 'Class_Article', - 'referenced_in' => 'parent_id'), - 'bib' => array('through' => 'categorie') - ); + 'article_original' => ['model' => 'Class_Article', + 'referenced_in' => 'parent_id'], + 'bib' => ['through' => 'categorie'], - protected $_overrided_attributes = array('id', - 'parent_id', - 'article_original', - 'langue', - 'titre', - 'description', - 'contenu'); + 'lieu' => ['model' => 'Class_Lieu', + 'referenced_in' => 'id_lieu'] ]; - protected $_default_attribute_values = array( + + protected $_overrided_attributes = ['id', + 'parent_id', + 'article_original', + 'langue', + 'titre', + 'description', + 'contenu']; + + protected $_default_attribute_values = [ 'titre' => '', 'description' => '', 'contenu' => '', @@ -428,7 +431,8 @@ class Class_Article extends Storm_Model_Abstract { 'date_maj' => '', 'date_creation' => '', 'status' => self::STATUS_DRAFT, - ); + 'id_lieu' => 0 + ]; /** * @return ArticleLoader diff --git a/tests/application/modules/admin/controllers/CmsControllerTest.php b/tests/application/modules/admin/controllers/CmsControllerTest.php index a8fdbb44c69f9e19828d294321ed6cca8f7ff7dc..ea4f09d585ebc61dc3773511f9c68873e2d9ad84 100644 --- a/tests/application/modules/admin/controllers/CmsControllerTest.php +++ b/tests/application/modules/admin/controllers/CmsControllerTest.php @@ -226,14 +226,14 @@ class CmsControllerArticleConcertAsAdminPortailEditActionTest extends CmsControl /** @test */ - public function selectIdLieuShouldContainsAucun() { - $this->assertXPath('//select[@name="id_lieu"]//option[@label="Aucun"][@value="0"]'); + public function selectIdLieuShouldContainsAucunAndBeSelected() { + $this->assertXPath('//select[@name="id_lieu"]//option[@selected="selected"][@label="Aucun"][@value="0"]'); } /** @test */ public function selectIdLieuShouldContainsBonlieu() { - $this->assertXPath('//select[@name="id_lieu"]//option[@label="Bonlieu"][@value="3"]'); + $this->assertXPath('//select[@name="id_lieu"]//option[not(@selected)][@label="Bonlieu"][@value="3"]'); } @@ -453,7 +453,8 @@ class CmsControllerArticleConcertEditActionPostTest extends CmsControllerTestCas 'events_debut' => '02/03/2011', 'events_fin' => '05/03/2011', 'contenu' => 'Ici: <img src="../../images/bonlieu.jpg" />', - 'description' => 'Affiche: <img src="http://localhost' . BASE_URL . '/images/concert.jpg" />'); + 'description' => 'Affiche: <img src="http://localhost' . BASE_URL . '/images/concert.jpg" />', + 'id_lieu' => 3); $this ->getRequest() @@ -543,6 +544,17 @@ class CmsControllerArticleConcertEditActionPostTest extends CmsControllerTestCas function categorieShouldBeEvenements() { $this->assertEquals($this->cat_evenements, $this->concert->getCategorie()); } + + + /** @test */ + public function lieuShouldBeBonlieu() { + $this->assertEquals($this->lieu_bonlieu, $this->concert->getLieu()); + } + + /** @test */ + public function comboLieuShouldHaveOptionBonlieuSelected() { + $this->assertXPath('//select[@name="id_lieu"]//option[@selected="selected"][@label="Bonlieu"][@value="3"]'); + } }