Skip to content

Commit

Permalink
Merge pull request #8 from patkar/enhancement/forward-compatibility-ftw
Browse files Browse the repository at this point in the history
Forward compatibility FTW (PHP 7, Symfony 3)
  • Loading branch information
pulse00 committed Mar 7, 2016
2 parents 05b3fa4 + 0989c72 commit 4301479
Show file tree
Hide file tree
Showing 13 changed files with 253 additions and 527 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
vendor
composer.phar
composer.lock
.DS_Store
43 changes: 43 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
language: php

php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm

sudo: false

cache:
directories:
- $HOME/.composer

env:
- SYMFONY_VERSION=2.8.*

matrix:
include:
- php: 5.6
env: SYMFONY_VERSION=2.3.*
- php: 5.6
env: SYMFONY_VERSION=2.7.*
- php: 7.0
env: SYMFONY_VERSION=2.8.*@dev
- php: 7.0
env: SYMFONY_VERSION=^3.0
- php: 7.0
env: SYMFONY_VERSION=^3.0@dev
- php: 5.3
env: COMPOSER_FLAGS="--prefer-lowest"

before_install:
- composer self-update
- if [ "$COMPOSER_FLAGS" == "--prefer-lowest" ]; then composer require "roave/security-advisories" dev-master --no-update; fi;
- if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update; fi;

install: composer update --prefer-source $COMPOSER_FLAGS

script:
- vendor/bin/phpunit
9 changes: 8 additions & 1 deletion DependencyInjection/DubtureFFmpegExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ public function load(array $configs, ContainerBuilder $container)
$config = $this->processConfiguration($configuration, $configs);

$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');

// Depending on the dependency injection version load the corresponding factories
// The new setFactory method was introduced in 2.6 and the old way removed in 3.0
if (method_exists('Symfony\\Component\\DependencyInjection\\Definition', 'setFactory')) {
$loader->load('factories.xml');
} else {
$loader->load('factories-2.3.xml');
}

$container->setParameter('dubture_ffmpeg.binary', $config['ffmpeg_binary']);
$container->setParameter('dubture_ffprobe.binary', $config['ffprobe_binary']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<parameters>
<parameter key="dubture_ffmpeg.ffmpeg.class">FFMpeg\FFMpeg</parameter>
<parameter key="dubture_ffmpeg.ffprobe.class">FFMpeg\FFProbe</parameter>
</parameters>

<services>
<service id="dubture_ffmpeg.ffmpeg" class="%dubture_ffmpeg.ffmpeg.class%" factory-class="%dubture_ffmpeg.ffmpeg.class%" factory-method="create" lazy="true">
<service id="dubture_ffmpeg.ffmpeg" class="FFMpeg\FFMpeg" factory-class="FFMpeg\FFMpeg" factory-method="create" lazy="true">
<argument type="collection">
<argument key="ffmpeg.binaries">%dubture_ffmpeg.binary%</argument>
<argument key="ffprobe.binaries">%dubture_ffprobe.binary%</argument>
Expand All @@ -20,13 +15,12 @@
<argument id="logger" type="service"/>
</service>

<service id="dubture_ffmpeg.ffprobe" class="%dubture_ffmpeg.ffprobe.class%" factory-class="%dubture_ffmpeg.ffprobe.class%" factory-method="create" lazy="true">
<service id="dubture_ffmpeg.ffprobe" class="FFMpeg\FFProbe" factory-class="FFMpeg\FFProbe" factory-method="create" lazy="true">
<argument type="collection">
<argument key="ffmpeg.binaries">%dubture_ffmpeg.binary%</argument>
<argument key="ffprobe.binaries">%dubture_ffprobe.binary%</argument>
</argument>
<argument id="logger" type="service"/>
</service>

</services>
</container>
28 changes: 28 additions & 0 deletions Resources/config/factories.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service id="dubture_ffmpeg.ffmpeg" class="FFMpeg\FFMpeg" lazy="true">
<factory class="FFMpeg\FFMpeg" method="create"/>
<argument type="collection">
<argument key="ffmpeg.binaries">%dubture_ffmpeg.binary%</argument>
<argument key="ffprobe.binaries">%dubture_ffprobe.binary%</argument>
<argument key="timeout">%dubture_ffmpeg.binary_timeout%</argument>
<argument key="ffmpeg.threads">%dubture_ffmpeg.threads_count%</argument>
</argument>
<argument id="logger" type="service"/>
</service>

<service id="dubture_ffmpeg.ffprobe" class="FFMpeg\FFProbe" lazy="true">
<factory class="FFMpeg\FFProbe" method="create"/>
<argument type="collection">
<argument key="ffmpeg.binaries">%dubture_ffmpeg.binary%</argument>
<argument key="ffprobe.binaries">%dubture_ffprobe.binary%</argument>
</argument>
<argument id="logger" type="service"/>
</service>
</services>
</container>
5 changes: 5 additions & 0 deletions Tests/Fixtures/all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dubture_f_fmpeg:
ffmpeg_binary: /usr/local/bin/ffmpeg
ffprobe_binary: /usr/local/bin/ffprobe
binary_timeout: 300
threads_count: 2
3 changes: 3 additions & 0 deletions Tests/Fixtures/minimum.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dubture_f_fmpeg:
ffmpeg_binary: /usr/local/bin/ffmpeg
ffprobe_binary: /usr/local/bin/ffprobe
66 changes: 66 additions & 0 deletions Tests/Unit/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

namespace Dubture\FFmpegBundle\Tests\Unit\DependencyInjection;

use Dubture\FFmpegBundle\DependencyInjection\Configuration;
use Dubture\FFmpegBundle\DependencyInjection\DubtureFFmpegExtension;
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionConfigurationTestCase;

/**
* Test the configuration parsed from YAML.
*
* @author Patrik Karisch <[email protected]>
*/
class ConfigurationTest extends AbstractExtensionConfigurationTestCase
{
/**
* {@inheritDoc}
*/
protected function getContainerExtension()
{
return new DubtureFFmpegExtension();
}

/**
* {@inheritDoc}
*/
protected function getConfiguration()
{
return new Configuration();
}

public function testProcessedMinimumConfigurationContainsAllValues()
{
$expectedConfiguration = array(
'ffmpeg_binary' => '/usr/local/bin/ffmpeg',
'ffprobe_binary' => '/usr/local/bin/ffprobe',
'binary_timeout' => 60,
'threads_count' => 4,
);

$sources = array(
__DIR__.'/../../Fixtures/minimum.yml',
);

$this->assertProcessedConfigurationEquals(
$expectedConfiguration,
$sources
);
}

public function testProcessedAllConfigurationContainsAllValues()
{
$expectedConfiguration = array(
'ffmpeg_binary' => '/usr/local/bin/ffmpeg',
'ffprobe_binary' => '/usr/local/bin/ffprobe',
'binary_timeout' => 300,
'threads_count' => 2,
);

$sources = array(
__DIR__.'/../../Fixtures/all.yml',
);

$this->assertProcessedConfigurationEquals($expectedConfiguration, $sources);
}
}
56 changes: 56 additions & 0 deletions Tests/Unit/DependencyInjection/DubtureFFmpegExtensionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

namespace Dubture\FFmpegBundle\Tests\Unit\DependencyInjection;

use Dubture\FFmpegBundle\DependencyInjection\DubtureFFmpegExtension;
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase;

/**
* Test the extensions which adds parameters and services
* to the container.
*
* @author Patrik Karisch <[email protected]>
*/
class DubtureFFmpegExtensionTest extends AbstractExtensionTestCase
{
/**
* {@inheritDoc}
*/
protected function getContainerExtensions()
{
return array(
new DubtureFFmpegExtension(),
);
}

/**
* {@inheritDoc}
*/
protected function setUp()
{
parent::setUp();

$this->load(array(
'ffmpeg_binary' => '/usr/local/bin/ffmpeg',
'ffprobe_binary' => '/usr/local/bin/ffprobe',
));
}

public function testAfterLoadingTheCorrectParametersHaveBeenSet()
{
$this->assertContainerBuilderHasParameter('dubture_ffmpeg.binary', '/usr/local/bin/ffmpeg');
$this->assertContainerBuilderHasParameter('dubture_ffprobe.binary', '/usr/local/bin/ffprobe');
$this->assertContainerBuilderHasParameter('dubture_ffmpeg.binary_timeout', 60);
$this->assertContainerBuilderHasParameter('dubture_ffmpeg.threads_count', 4);
}

public function testAfterLoadingTheFFMpegServiceExists()
{
$this->assertContainerBuilderHasService('dubture_ffmpeg.ffmpeg', 'FFMpeg\FFMpeg');
}

public function testAfterLoadingTheFFProbeServiceExists()
{
$this->assertContainerBuilderHasService('dubture_ffmpeg.ffprobe', 'FFMpeg\FFProbe');
}
}
8 changes: 8 additions & 0 deletions Tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

$file = __DIR__ . '/../vendor/autoload.php';
if (!file_exists($file)) {
throw new RuntimeException('Install dependencies to run test suite.');
}

$autoload = require_once $file;
24 changes: 14 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
{
"name": "pulse00/ffmpeg-bundle",
"type": "symfony-bundle",
"description": "Symfony bundle to provide PHP-FFmpeg as a Symfony service (https://github.com/alchemy-fr/PHP-FFmpeg)",
"keywords": ["ffmpeg", "multimedia"],
"keywords": ["multimedia", "video processing", "video", "audio processing", "audio", "avconv", "ffmpeg", "avprobe", "ffprobe"],
"license": "MIT",
"type": "symfony-bundle",
"require": {
"php-ffmpeg/php-ffmpeg": "0.5.*@dev"
},
"minimum-stability": "dev",
"authors": [
{
"name": "Robert Gruendler",
"email": "[email protected]"
}
],
"autoload": {
"psr-0": { "Dubture\\FFmpegBundle": "" }
"require": {
"php": "^5.3.9 || ^7.0",
"php-ffmpeg/php-ffmpeg": "^0.5 || ^0.6",
"symfony/dependency-injection": "^2.3 || ^3.0",
"symfony/framework-bundle": "^2.3 || ^3.0"
},
"target-dir": "Dubture/FFmpegBundle"

"require-dev": {
"matthiasnoback/symfony-dependency-injection-test": "~0.7",
"phpunit/phpunit": "^4.8"
},
"autoload": {
"psr-4": { "Dubture\\FFmpegBundle\\": "" }
}
}
Loading

0 comments on commit 4301479

Please sign in to comment.