diff --git a/README.md b/README.md index 90a4acd1..38ae5293 100644 --- a/README.md +++ b/README.md @@ -130,11 +130,11 @@ system to use with PrestaSitemap. * Follow the instruction to install [LiipDoctrineCacheBundle](http://packagist.org/packages/liip/doctrine-cache-bundle). * Configure a service for PrestaSitemap, this is an exemple with php-apc : - #config.yml - liip_doctrine_cache: - namespaces: - presta_sitemap: - type: apc + #config.yml + liip_doctrine_cache: + namespaces: + presta_sitemap: + type: apc ## Deeper informations diff --git a/Tests/Controller/SitemapControllerTest.php b/Tests/Controller/SitemapControllerTest.php index a0eafcd8..98e1ccf2 100644 --- a/Tests/Controller/SitemapControllerTest.php +++ b/Tests/Controller/SitemapControllerTest.php @@ -3,35 +3,55 @@ namespace Presta\SitemapBundle\Tests\Controller; use Presta\SitemapBundle\Controller; +use Presta\SitemapBundle\Event\SitemapPopulateEvent; use Presta\SitemapBundle\Service\Generator; +use Presta\SitemapBundle\Sitemap\Url; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; class SitemapControllerTest extends WebTestCase { - public function testIndexAction() + + public function setUp() { //boot appKernel self::createClient(); + $this->container = static::$kernel->getContainer(); - $container = static::$kernel->getContainer(); - $controller = new Controller\SitemapController(); - $controller->setContainer($container); + //set controller to test + $this->controller = new Controller\SitemapController(); + $this->controller->setContainer($this->container); - $response = $controller->indexAction(); + //------------------- + // add url to sitemap + $this->container->get('event_dispatcher') + ->addListener(SitemapPopulateEvent::onSitemapPopulate, function(SitemapPopulateEvent $event) { + $event->getGenerator()->addUrl( + new Url\UrlConcrete( + 'http://acme.com/static-page.html', + new \DateTime(), + Url\UrlConcrete::CHANGEFREQ_HOURLY, 1), + 'default'); + }); + //------------------- + + } + + public function testIndexAction() + { + $response = $this->controller->indexAction(); $this->isInstanceOf('Symfony\Component\HttpFoundation\Response', $response); } - public function testSectionAction() + public function testValidSectionAction() + { + $response = $this->controller->sectionAction('default'); + $this->isInstanceOf('Symfony\Component\HttpFoundation\Response', $response); + } + + public function testNotFoundSectionAction() { - //boot appKernel - self::createClient(); - $container = static::$kernel->getContainer(); - - $controller = new Controller\SitemapController(); - $controller->setContainer($container); - try { - $controller->sectionAction('void'); + $this->controller->sectionAction('void'); $this->fail('section "void" does\'nt exist'); } catch (\Symfony\Component\HttpKernel\Exception\NotFoundHttpException $e) { //this is ok diff --git a/composer.json b/composer.json index c7286331..561c0902 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "presta/sitemap-bundle", - "description": "This Bundle provides a sitemap generator for symfony2.", - "keywords": ["symfony2", "sitemap", "xml"], + "description": "A symfony 2 bundle that provides tools to build your application sitemap.", + "keywords": ["symfony2", "bundle", "sitemap", "xml"], "type": "symfony-bundle", "license": "MIT", "authors": [ @@ -12,11 +12,11 @@ ], "require": { "php": ">=5.3.0", - "symfony/symfony": ">=2.1", - "doctrine/common": ">=2.2", - "liip/doctrine-cache-bundle" : "*" - } - , + "symfony/symfony": ">=2.1" + }, + "suggest": { + "liip/doctrine-cache-bundle" : "Allows to store sitemaps in cache" + }, "autoload": { "psr-0": { "Presta\\SitemapBundle\\": "" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index f725e2fa..51665f58 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,17 +1,13 @@ - - - ./Tests - ./