diff --git a/library/Class/Profil.php b/library/Class/Profil.php index 3522a7f39ed36a029cf16a1ccaceccb79de0974c..10a55343ccb09e20c8e46e3c6275ac643844209d 100644 --- a/library/Class/Profil.php +++ b/library/Class/Profil.php @@ -551,10 +551,18 @@ class Class_Profil extends Storm_Model_Abstract { public function getUrl() { - return Class_Url::siteUrl() . $this->getPath(); + return Class_Url::siteUrl() . '/' . $this->getProfilPath(); } + public function getProfilPath() { + return $this->getRewriteUrl() + ? $this->getRewriteUrl() + : 'index/index?'. http_build_query(['id_profil' => $this->getId()]); + } + + + public function getUrlParts() { if (!$this->hasRewriteUrl()) return ['id_profil' => $this->getId()]; @@ -2088,12 +2096,5 @@ class Class_Profil extends Storm_Model_Abstract { return $this->getLargeurSite(). ($this->getSizeSiteScale()=="percent"? "%":"px"); } - - - public function getPath() { - return $this->getRewriteUrl() - ? '/' . $this->getRewriteUrl() - : '?id_profil=' . $this->getId(); - } } ?> diff --git a/tests/library/Class/BatchTest.php b/tests/library/Class/BatchTest.php index 8db0c363fe2e3bf83c52f50cdb6ab10b8521e24c..f6ec20097cee1fc5d62d996a95ec166cbcc519a8 100644 --- a/tests/library/Class/BatchTest.php +++ b/tests/library/Class/BatchTest.php @@ -184,6 +184,12 @@ class BatchBuildSitemapTest extends Storm_Test_ModelTestCase { 'libelle' => 'Services', 'parent_id' => '2', 'cfg_accueil' => ZendAfi_Filters_Serialize::serialize(['sitemap' => 0])]); + $this->_profiles[4] = $this->fixture('Class_Profil', + ['id' => 4, + 'libelle' => 'url rewriting', + 'cfg_accueil' => ZendAfi_Filters_Serialize::serialize(['sitemap' => 1]), + 'rewrite_url' => 'my-url']); + Class_Profil::beVolatile(); $this->handle = new stdClass; @@ -197,7 +203,7 @@ class BatchBuildSitemapTest extends Storm_Test_ModelTestCase { $this->fixture('Class_AdminVar', ['id' => 'NOM_DOMAINE', 'clef' => 'NOM_DOMAINE', - 'valeur' => 'http://wiki.bokeh-library-portal.org/']); + 'valeur' => 'http://wiki.bokeh-library-portal.org']); } @@ -208,12 +214,17 @@ class BatchBuildSitemapTest extends Storm_Test_ModelTestCase { $expected = '<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <url> - <loc>http://wiki.bokeh-library-portal.org/?id_profil=1</loc> + <loc>http://wiki.bokeh-library-portal.org/index/index?id_profil=1</loc> <priority>1.0</priority> <changefreq>weekly</changefreq> </url> <url> - <loc>http://wiki.bokeh-library-portal.org/?id_profil=2</loc> + <loc>http://wiki.bokeh-library-portal.org/index/index?id_profil=2</loc> + <priority>0.8</priority> + <changefreq>weekly</changefreq> + </url> + <url> + <loc>http://wiki.bokeh-library-portal.org/my-url</loc> <priority>0.8</priority> <changefreq>weekly</changefreq> </url> @@ -225,10 +236,12 @@ class BatchBuildSitemapTest extends Storm_Test_ModelTestCase { [$this->handle, $expected])); } + /** @test */ public function sitemapFileShouldBeRemoved() { $this->_profiles[1]->setCfgAccueilParam('sitemap', 0); $this->_profiles[2]->setCfgAccueilParam('sitemap', 0); + $this->_profiles[4]->setCfgAccueilParam('sitemap', 0); (new Class_Batch_BuildSiteMap())->run(); $this->assertTrue($this->_file_system ->methodHasBeenCalledWithParams('unlink',