Skip to content

Commit

Permalink
Updated Travis testing matrix (prestaconcept#145)
Browse files Browse the repository at this point in the history
* Updated Travis testing matrix

* Fixing Travis build

* Fixing Travis build

* Fixed risky tests

* Removed HHVM in favor of PHP 7.1

* Removed unecessary bundles in test app

* Adde security config to test app to avoid deprecations

* Do not get router.request_context service directly to avoid deprecations

* Fixed PhpUnit and Symfony4 deprecations
  • Loading branch information
yann-eugone authored Aug 7, 2017
1 parent f6520b7 commit e797d33
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*~
Tests/app/cache/
composer.lock
phpunit.xml
vendor/
Tests/web
15 changes: 9 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ language: php
php:
- 5.6
- 7.0
- hhvm
- 7.1

matrix:
include:
Expand All @@ -15,12 +15,14 @@ matrix:
env: SYMFONY_VERSION=2.8.* SYMFONY_DEPRECATIONS_HELPER=strict
- php: 5.6
env: SYMFONY_VERSION=3.0.* SYMFONY_DEPRECATIONS_HELPER=strict
- php: 5.6
env: SYMFONY_VERSION=3.2.*@dev SYMFONY_DEPRECATIONS_HELPER=strict
- php: 7.0
env: PHPCS=yes
env: SYMFONY_VERSION=3.2.* SYMFONY_DEPRECATIONS_HELPER=strict
- php: 7.1
env: SYMFONY_VERSION=3.3.* SYMFONY_DEPRECATIONS_HELPER=strict
- php: 7.1
env: SYMFONY_VERSION=3.4.*@dev SYMFONY_DEPRECATIONS_HELPER=strict
allow_failures:
- env: SYMFONY_VERSION=3.2.*@dev
- env: SYMFONY_VERSION=3.4.*@dev

env:
global:
Expand All @@ -36,7 +38,8 @@ before_install:
- if [ "$PHPCS" = "yes" ]; then pear install pear/PHP_CodeSniffer; fi
- if [ "$PHPCS" = "yes" ]; then phpenv rehash; fi
- if [ "$PHPCS" != "yes"]; then composer selfupdate; fi
- if [ "$SYMFONY_VERSION" = "3.2.*@dev" ]; then composer require --no-update twig/twig:~2.0@dev; fi
- if [ "$SYMFONY_VERSION" = "3.4.*@dev" ]; then rm -f phpunit.xml; cp phpunit.sf4.xml.dist phpunit.xml; fi
- if [ "$SYMFONY_VERSION" = "3.2.*" ] || [ "$SYMFONY_VERSION" = "3.3.*" ] || [ "$SYMFONY_VERSION" = "3.4.*@dev" ]; then composer require --no-update twig/twig:~2.0; fi
- if [ "$SYMFONY_VERSION" != "" ]; then composer require --no-update symfony/symfony:${SYMFONY_VERSION}; fi

install: if [ "$PHPCS" != "yes" ]; then composer update --prefer-dist; fi
Expand Down
2 changes: 1 addition & 1 deletion Command/DumpSitemapsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
*/
private function getBaseUrl()
{
$context = $this->getContainer()->get('router.request_context');
$context = $this->getContainer()->get('router')->getContext();

if ('' === $host = $context->getHost()) {
throw new \RuntimeException(
Expand Down
27 changes: 18 additions & 9 deletions Tests/Controller/SitemapControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,20 @@
use Presta\SitemapBundle\Service\Generator;
use Presta\SitemapBundle\Sitemap\Url;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\DependencyInjection\ContainerInterface;

class SitemapControllerTest extends WebTestCase
{
/**
* @var Controller\SitemapController
*/
private $controller;

/**
* @var ContainerInterface
*/
private $container;

public function setUp()
{
//boot appKernel
Expand Down Expand Up @@ -51,23 +62,21 @@ function (SitemapPopulateEvent $event) {

public function testIndexAction()
{
$response = $this->controller->indexAction();
$this->isInstanceOf('Symfony\Component\HttpFoundation\Response', $response);
$response = $this->controller->indexAction();
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response);
}

public function testValidSectionAction()
{
$response = $this->controller->sectionAction('default');
$this->isInstanceOf('Symfony\Component\HttpFoundation\Response', $response);
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response);
}

/**
* @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
*/
public function testNotFoundSectionAction()
{
try {
$this->controller->sectionAction('void');
$this->fail('section "void" does\'nt exist');
} catch (\Symfony\Component\HttpKernel\Exception\NotFoundHttpException $e) {
//this is ok
}
$this->controller->sectionAction('void');
}
}
2 changes: 2 additions & 0 deletions Tests/Service/GeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function testGenerate()
{
try {
$this->generator->generate();
$this->assertTrue(true, 'No exception was thrown');
} catch (\RuntimeException $e) {
$this->fail('No exception must be thrown');
}
Expand All @@ -49,6 +50,7 @@ public function testAddUrl()
{
try {
$this->generator->addUrl(new Sitemap\Url\UrlConcrete('http://acme.com/'), 'default');
$this->assertTrue(true, 'No exception was thrown');
} catch (\RuntimeException $e) {
$this->fail('No exception must be thrown');
}
Expand Down
2 changes: 0 additions & 2 deletions Tests/app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ public function registerBundles()
// Dependencies
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
//new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
//new JMS\SerializerBundle\JMSSerializerBundle($this),
new Presta\SitemapBundle\PrestaSitemapBundle(),
);

Expand Down
11 changes: 11 additions & 0 deletions Tests/app/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,14 @@ framework:
validation: { enable_annotations: true }
session:
storage_id: session.storage.filesystem

security:
providers:
in_memory:
memory: ~
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
anonymous: ~
20 changes: 10 additions & 10 deletions Tests/fixtures/sitemap.video.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
<url>
<loc>http://sitemap.php54.local/page_video1/</loc>
<video:video>
<video:thumbnail_loc>http://sitemap.php54.local/page_video1/thumbnail_loc?a=b&amp;b=c</video:thumbnail_loc>
<video:title><![CDATA[Title & spécial chars]]></video:title>
<video:description><![CDATA[The description & spécial chars]]></video:description>
<video:content_loc>http://sitemap.php54.local/page_video1/content?format=mov&amp;a=b</video:content_loc>
<video:gallery_loc title="Gallery title &amp; spécial chars">http://sitemap.php54.local/page_video1/gallery_loc/?p=1&amp;sort=desc</video:gallery_loc>
</video:video>
</url>
<url>
<loc>http://sitemap.php54.local/page_video1/</loc>
<video:video>
<video:thumbnail_loc>http://sitemap.php54.local/page_video1/thumbnail_loc?a=b&amp;b=c</video:thumbnail_loc>
<video:title><![CDATA[Title & spécial chars]]></video:title>
<video:description><![CDATA[The description & spécial chars]]></video:description>
<video:content_loc>http://sitemap.php54.local/page_video1/content?format=mov&amp;a=b</video:content_loc>
<video:gallery_loc title="Gallery title &amp; spécial chars">http://sitemap.php54.local/page_video1/gallery_loc/?p=1&amp;sort=desc</video:gallery_loc>
</video:video>
</url>
</urlset>
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"symfony/symfony": "~2.2|~3.0"
},
"require-dev": {
"symfony/phpunit-bridge": "~2.7|~3.0"
"symfony/phpunit-bridge": "~2.7|~3.0",
"phpunit/phpunit": "4.*"
},
"suggest": {
"doctrine/doctrine-cache-bundle" : "Allows to store sitemaps in cache"
Expand All @@ -34,6 +35,11 @@
"Presta\\SitemapBundle\\": ""
}
},
"autoload-dev": {
"files": [
"Tests/app/AppKernel.php"
]
},
"extra": {
"branch-alias": {
"dev-master": "1.5.x-dev"
Expand Down
22 changes: 22 additions & 0 deletions phpunit.sf4.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./Tests/bootstrap.php" colors="true">
<php>
<server name="KERNEL_CLASS" value="AppKernel" />
</php>
<testsuites>
<testsuite name="PrestaSitemapBundle test suite">
<directory suffix="Test.php">./Tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./</directory>
<exclude>
<directory>./Resources</directory>
<directory>./Tests</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>
</phpunit>

0 comments on commit e797d33

Please sign in to comment.