Skip to content

Commit

Permalink
[tests] fixes for standalone testing
Browse files Browse the repository at this point in the history
+ fix typo in readme, composer
+ remove not required libs from composer
  • Loading branch information
David EPELY committed Jul 4, 2012
1 parent 5486c8c commit 7f9af24
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 30 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
48 changes: 34 additions & 14 deletions Tests/Controller/SitemapControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand All @@ -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\\": ""
Expand Down
4 changes: 0 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="./Tests/bootstrap.php" colors="true">

<php>
<server name="KERNEL_DIR" value="Tests/app" />
</php>

<testsuites>
<testsuite name="PrestaSitemapBundle test suite">
<directory suffix="Test.php">./Tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>./</directory>
Expand Down

0 comments on commit 7f9af24

Please sign in to comment.