diff --git a/library/ZendAfi/Validate/ProfilRewriteUrl.php b/library/ZendAfi/Validate/ProfilRewriteUrl.php index b6d5f3716440587737ecff1a0ff2cb15eea20312..7055e4d79544975fe9e8c12689e57934a37fdf99 100644 --- a/library/ZendAfi/Validate/ProfilRewriteUrl.php +++ b/library/ZendAfi/Validate/ProfilRewriteUrl.php @@ -87,9 +87,9 @@ class ZendAfi_Validate_ProfilRewriteUrl extends Zend_Validate_Abstract { $profils = array_filter($profils, function ($model) use ($page) { return $model->hasParentProfil() - && ($model->getParent()->getRewriteUrl()) && ($model->getId() !== $page->getId()) - && ($model->getParent()->getRewriteUrl() == $page->getParent()->getRewriteUrl());}); + && ($model->getParent()->getRewriteUrl() == $page->getParent()->getRewriteUrl()); + }); if (count($profils)==0) return true; diff --git a/tests/library/Class/ProfilTest.php b/tests/library/Class/ProfilTest.php index 319930150f73db1fae72301f06ea6018d6ad828b..b06a658c0f6613afee6877b81dc411d9db0e5d5a 100644 --- a/tests/library/Class/ProfilTest.php +++ b/tests/library/Class/ProfilTest.php @@ -749,6 +749,7 @@ class ProfilAdulteChatenayTest extends ProfilAdulteChatenayTestCase { implode(',', $this->profil->getErrors())); } + /** @test */ public function pageWithParentProfilWithoutRewriteUrlShouldBeValid() { $this->page_nature = Class_Profil::newInstance([ @@ -760,6 +761,28 @@ class ProfilAdulteChatenayTest extends ProfilAdulteChatenayTestCase { } + + /** @test */ + public function twoPagesWithParentProfilWithoutRewriteUrlAndSameUrlShouldNotBeValid() { + $this->fixture('Class_Profil', ['id' => 345, + 'parent_id' => null, + 'libelle' => 'one profile', + 'rewrite_url' => '']); + + $this->fixture('Class_Profil', ['id' => 543, + 'parent_id' => 1, + 'libelle' => 'Nature', + 'rewrite_url' => 'nature']); + + $page_nature = Class_Profil::newInstance([ + 'parent_id' => 1, + 'libelle' => 'Nature', + 'rewrite_url' => 'nature']); + + $this->assertFalse($page_nature->isValid()); + } + + /** @test */ public function pageWithParentProfilWithSameRewriteUrlAsAnotherProfilShouldBeValid() { $this->profil_nature = $this->fixture('Class_Profil',