Skip to content

Commit

Permalink
Merge pull request #14 from rjkip/maintenance/symfony-3-php-7-support
Browse files Browse the repository at this point in the history
Test support for Symfony LTSes and 3.0, PHP 5 through 7
  • Loading branch information
wtfzdotnet committed Mar 11, 2016
2 parents 00d9bcc + 31589ad commit badb985
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 30 deletions.
43 changes: 43 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
sudo: false
language: php

php:
- 5.4
- 5.5
- nightly
- hhvm

cache:
directories:
- ~/.composer/cache

before_script:
- composer self-update
- if [ "$SYMFONY_VERSION" != "" ]; then composer require --no-update symfony/config:${SYMFONY_VERSION} symfony/dependency-injection:${SYMFONY_VERSION} symfony/event-dispatcher:${SYMFONY_VERSION} symfony/http-kernel:${SYMFONY_VERSION} symfony/framework-bundle:${SYMFONY_VERSION}; fi;
- if [ "$SYMFONY_EVENT_DISPATCHER_VERSION" != "" ]; then composer require --no-update symfony/event-dispatcher:${SYMFONY_EVENT_DISPATCHER_VERSION}; fi;
- composer install --no-interaction --prefer-source --dev

script: phpunit --verbose

matrix:
include:
- php: 5.6
env: [SYMFONY_VERSION="2.3.*", SYMFONY_EVENT_DISPATCHER_VERSION="2.4.*"]
- php: 5.6
env: [SYMFONY_VERSION="2.7.*"]
- php: 5.6
env: [SYMFONY_VERSION="2.8.*"]
- php: 5.6
env: [SYMFONY_VERSION="3.0.*"]
- php: 7.0
env: [SYMFONY_VERSION="2.3.*", SYMFONY_EVENT_DISPATCHER_VERSION="2.4.*"]
- php: 7.0
env: [SYMFONY_VERSION="2.7.*"]
- php: 7.0
env: [SYMFONY_VERSION="2.8.*"]
- php: 7.0
env: [SYMFONY_VERSION="3.0.*"]
allow_failures:
- php: nightly
- php: hhvm
fast_finish: true
30 changes: 30 additions & 0 deletions Tests/DependencyInjection/TmdbSymfonyExtensionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Tmdb\SymfonyBundle\Tests\DependencyInjection;

use PHPUnit_Framework_TestCase as TestCase;
use Symfony\Component\DependencyInjection\Container;
use Tmdb\SymfonyBundle\Tests\TestKernel;

final class TmdbSymfonyExtensionTest extends TestCase
{
/**
* @test
* @group DependencyInjection
*/
public function all_tmdb_services_can_be_loaded()
{
$kernel = new TestKernel('test', true);
$kernel->boot();

/** @var Container $container */
$container = $kernel->getContainer();
$tmdbServiceIds = array_filter($container->getServiceIds(), function ($id) {
return strpos($id, 'tmdb') === 0;
});

foreach ($tmdbServiceIds as $serviceId) {
$container->get($serviceId);
}
}
}
39 changes: 39 additions & 0 deletions Tests/TestKernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace Tmdb\SymfonyBundle\Tests;

use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\HttpKernel\Kernel;
use Tmdb\SymfonyBundle\TmdbSymfonyBundle;

final class TestKernel extends Kernel
{
public function registerBundles()
{
return [
new FrameworkBundle(),
new TmdbSymfonyBundle()
];
}

public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__ . '/config.yml');
}

public function getRootDir()
{
return sys_get_temp_dir() . '/php-tmdb-symfony-test';
}

public function getCacheDir()
{
return $this->getRootDir() . '/cache';
}

public function getLogDir()
{
return $this->getRootDir() . '/logs';
}
}
4 changes: 4 additions & 0 deletions Tests/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
framework:
secret: NopeChuckTesta
tmdb_symfony:
api_key: invalidapikey
45 changes: 17 additions & 28 deletions Twig/TmdbExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@

class TmdbExtension extends \Twig_Extension
{
/**
* @var ImageHelper|null
*/
private $helper;

/**
* @var Client
*/
private $client;

private $configuration;

public function __construct(Client $client)
{
$this->client = $client;

$repository = new ConfigurationRepository($client);
$config = $repository->load();

$this->helper = new ImageHelper($config);
}

public function getFilters()
Expand All @@ -34,12 +33,12 @@ public function getFilters()

public function getHtml($image, $size = 'original', $width = null, $height = null)
{
return $this->helper->getHtml($image, $size, $width, $height);
return $this->getHelper()->getHtml($image, $size, $width, $height);
}

public function getUrl($image)
{
return $this->helper->getUrl($image);
return $this->getHelper()->getUrl($image);
}

public function getName()
Expand All @@ -66,25 +65,6 @@ public function getClient()
return $this->client;
}

/**
* @param mixed $configuration
* @return $this
*/
public function setConfiguration($configuration)
{
$this->configuration = $configuration;

return $this;
}

/**
* @return mixed
*/
public function getConfiguration()
{
return $this->configuration;
}

/**
* @param ImageHelper $helper
* @return $this
Expand All @@ -101,6 +81,15 @@ public function setHelper($helper)
*/
public function getHelper()
{
if ($this->helper) {
return $this->helper;
}

$repository = new ConfigurationRepository($this->client);
$config = $repository->load();

$this->helper = new ImageHelper($config);

return $this->helper;
}
}
13 changes: 11 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,18 @@
}
],
"require": {
"symfony/symfony": "~2.3",
"php": ">=5.4.0",
"symfony/config": ">=2.3,<4",
"symfony/dependency-injection": ">=2.3,<4",
"symfony/event-dispatcher": ">=2.3,<4",
"symfony/http-kernel": ">=2.3,<4",
"doctrine/doctrine-cache-bundle": "~1.0",
"php-tmdb/api": "~2.0"
"php-tmdb/api": "^2.0.14",
"twig/twig": "~1.11|~2.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8",
"symfony/framework-bundle": ">=2.3,<4"
},
"autoload": {
"psr-4": { "Tmdb\\SymfonyBundle\\": "" }
Expand Down
16 changes: 16 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="vendor/autoload.php">
<testsuites>
<testsuite name="php-tmdb-symfony Test Suite">
<directory>./Tests/</directory>
</testsuite>
</testsuites>
</phpunit>

0 comments on commit badb985

Please sign in to comment.