Skip to content
Snippets Groups Projects
Commit 3d39af5f authored by Ghislain Loas's avatar Ghislain Loas
Browse files

hotline #30747 : fix cms_categories with same id and parent_id

parent 24e60f76
Branches
Tags
1 merge request!1149Hotline#30747 cms categories with same id and parent
- 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
...@@ -70,6 +70,8 @@ class Class_ArticleCategorie extends Storm_Model_Abstract { ...@@ -70,6 +70,8 @@ class Class_ArticleCategorie extends Storm_Model_Abstract {
$filter = new Zend_Filter_StripTags(); $filter = new Zend_Filter_StripTags();
$this->setLibelle(trim($filter->filter($this->getLibelle()))); $this->setLibelle(trim($filter->filter($this->getLibelle())));
if($this->getId() === $this->getIdCatMere())
$this->setIdCatMere(0);
} }
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* *
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software * 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 { class ArticleCategorieTest extends Storm_Test_ModelTestCase {
...@@ -82,7 +82,7 @@ class ArticleCategorieTest extends Storm_Test_ModelTestCase { ...@@ -82,7 +82,7 @@ class ArticleCategorieTest extends Storm_Test_ModelTestCase {
->answers(true) ->answers(true)
->getWrapper(); ->getWrapper();
$this->concert_truffaz = Class_Article::newInstanceWithId(23, ['id_cat' => 34, $this->concert_truffaz = Class_Article::newInstanceWithId(23, ['id_cat' => 34,
'titre' => 'Concert Truffaz']); 'titre' => 'Concert Truffaz']);
...@@ -169,9 +169,9 @@ class ArticleCategorieTest extends Storm_Test_ModelTestCase { ...@@ -169,9 +169,9 @@ class ArticleCategorieTest extends Storm_Test_ModelTestCase {
} }
/** /**
* Régression vue sur Pontault * Régression vue sur Pontault
* @test * @test
*/ */
public function annecyWithCarriageReturnToJSONShouldRemoveCR() { public function annecyWithCarriageReturnToJSONShouldRemoveCR() {
$this->annecy->setLibelle("Annecy\n"); $this->annecy->setLibelle("Annecy\n");
...@@ -317,11 +317,11 @@ JSON; ...@@ -317,11 +317,11 @@ JSON;
/** @test */ /** @test */
public function findByPathAdulteConcertsJazzShouldAnswerCategorieJazz() { public function findByPathAdulteConcertsJazzShouldAnswerCategorieJazz() {
$this->assertEquals($this->cat_concerts_jazz, $this->assertEquals($this->cat_concerts_jazz,
Class_ArticleCategorie::getRoot()->findByPath('/Adulte/Concerts/Jazz')); Class_ArticleCategorie::getRoot()->findByPath('/Adulte/Concerts/Jazz'));
} }
/** @test **/ /** @test **/
public function profilConcertPathAndCategorieConcertPathShouldBeEquals() { public function profilConcertPathAndCategorieConcertPathShouldBeEquals() {
$this->assertEquals($this->cat_concerts->getPath(), $this->concert_profil->getPath()); $this->assertEquals($this->cat_concerts->getPath(), $this->concert_profil->getPath());
...@@ -334,4 +334,27 @@ JSON; ...@@ -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
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