Skip to content

Commit

Permalink
Add tests, support PHP 7 and add travis build config
Browse files Browse the repository at this point in the history
  • Loading branch information
QuingKhaos committed Mar 5, 2016
1 parent 17024ee commit 8bd7a9d
Show file tree
Hide file tree
Showing 8 changed files with 196 additions and 1 deletion.
34 changes: 34 additions & 0 deletions .travis.yml
@@ -0,0 +1,34 @@
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

before_install:
- if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update; fi;

install: composer update --prefer-source $COMPOSER_FLAGS

script:
- vendor/bin/phpunit
5 changes: 5 additions & 0 deletions Tests/Fixtures/all.yml
@@ -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
@@ -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
@@ -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 <patrik@karisch.guru>
*/
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
@@ -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 <patrik@karisch.guru>
*/
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
@@ -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;
6 changes: 5 additions & 1 deletion composer.json
Expand Up @@ -11,10 +11,14 @@
}
],
"require": {
"php": "^5.3.9",
"php": "^5.3.9 || ^7.0",
"php-ffmpeg/php-ffmpeg": "^0.5",
"symfony/framework-bundle": "^2.3"
},
"require-dev": {
"matthiasnoback/symfony-dependency-injection-test": "~0.7",
"phpunit/phpunit": "^4.8"
},
"autoload": {
"psr-4": { "Dubture\\FFmpegBundle\\": "" }
}
Expand Down
19 changes: 19 additions & 0 deletions phpunit.xml.dist
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./Tests/bootstrap.php" colors="true">
<testsuites>
<testsuite name="unit">
<directory suffix="Test.php">./Tests/Unit</directory>
</testsuite>
</testsuites>

<!-- Code coverage filter -->
<filter>
<whitelist>
<directory>./</directory>
<exclude>
<directory>./Tests</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>
</phpunit>

0 comments on commit 8bd7a9d

Please sign in to comment.