diff --git a/VERSIONS_HOTLINE/30747 b/VERSIONS_HOTLINE/30747 new file mode 100644 index 0000000000000000000000000000000000000000..1097a362ccb1d1085a4d9e4eeaf2bd95c3ff0962 --- /dev/null +++ b/VERSIONS_HOTLINE/30747 @@ -0,0 +1 @@ + - ticket #30747 : Correction de la possibilité de déclarer une catégorie d'article comme étant sa propre catégorie parente. \ No newline at end of file diff --git a/library/Class/ArticleCategorie.php b/library/Class/ArticleCategorie.php index 9e1cc7b6957ce2119002412439ec68f2d23cf3a1..edf5dbe37d59d307a47afa328e52622628782968 100644 --- a/library/Class/ArticleCategorie.php +++ b/library/Class/ArticleCategorie.php @@ -70,6 +70,8 @@ class Class_ArticleCategorie extends Storm_Model_Abstract { $filter = new Zend_Filter_StripTags(); $this->setLibelle(trim($filter->filter($this->getLibelle()))); + if($this->getId() === $this->getIdCatMere()) + $this->setIdCatMere(0); } diff --git a/tests/library/Class/ArticleCategorieTest.php b/tests/library/Class/ArticleCategorieTest.php index 8d06fbf1fed035278c08832b3951e39fe108eca5..577bc2b52af6407d6643433d80b96892cf1140c1 100644 --- a/tests/library/Class/ArticleCategorieTest.php +++ b/tests/library/Class/ArticleCategorieTest.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; 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 */ class ArticleCategorieTest extends Storm_Test_ModelTestCase { @@ -82,7 +82,7 @@ class ArticleCategorieTest extends Storm_Test_ModelTestCase { ->answers(true) ->getWrapper(); - + $this->concert_truffaz = Class_Article::newInstanceWithId(23, ['id_cat' => 34, 'titre' => 'Concert Truffaz']); @@ -169,9 +169,9 @@ class ArticleCategorieTest extends Storm_Test_ModelTestCase { } - /** + /** * Régression vue sur Pontault - * @test + * @test */ public function annecyWithCarriageReturnToJSONShouldRemoveCR() { $this->annecy->setLibelle("Annecy\n"); @@ -317,11 +317,11 @@ JSON; /** @test */ public function findByPathAdulteConcertsJazzShouldAnswerCategorieJazz() { - $this->assertEquals($this->cat_concerts_jazz, + $this->assertEquals($this->cat_concerts_jazz, Class_ArticleCategorie::getRoot()->findByPath('/Adulte/Concerts/Jazz')); } - + /** @test **/ public function profilConcertPathAndCategorieConcertPathShouldBeEquals() { $this->assertEquals($this->cat_concerts->getPath(), $this->concert_profil->getPath()); @@ -334,4 +334,27 @@ JSON; } } -?> \ No newline at end of file + + +class ArticleCategorieParentTest extends Storm_Test_ModelTestCase { + protected $_news; + + public function setUp() { + parent::setUp(); + + $annecy = $this->fixture('Class_Bib', + ['id' => 1, + 'libelle' => 'Annecy']); + + $this->_news = $this->fixture('Class_ArticleCategorie', + ['id' => 5, + 'id_cat_mere' => 5, + 'libelle' => 'News']); + } + + + /** @test */ + public function newsParentCategorieShouldBe0() { + $this->assertEquals('0', $this->_news->getIdCatMere()); + } +} \ No newline at end of file