Merge pull request #845 from PHP-FFMpeg/improve-github-actions
Update test.yaml
This commit is contained in:
commit
c69632a2be
12 changed files with 142 additions and 127 deletions
118
.github/workflows/test.yaml
vendored
118
.github/workflows/test.yaml
vendored
|
|
@ -1,80 +1,66 @@
|
||||||
name: Test
|
name: Test
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request: ~
|
pull_request: ~
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- 'master'
|
- "master"
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "0 0 * * *"
|
- cron: "0 0 * * *"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
name: "PHP ${{ matrix.php-version }} ${{ matrix.dependency-versions }} ${{ matrix.composer-stability }}"
|
name: "PHP ${{ matrix.php-version }} ${{ matrix.dependency-versions }} ${{ matrix.composer-stability }}"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
env:
|
env:
|
||||||
PHPUNIT_VERSION: ${{ matrix.phpunit-version }}
|
PHPUNIT_VERSION: ${{ matrix.phpunit-version }}
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
os: [ubuntu-20.04]
|
||||||
- php-version: '5.3'
|
php-version: [8.1, 8.0, 7.4, 7.3, 7.2, 7.1, 7.0, 5.6, 5.5]
|
||||||
phpunit-version: 4
|
dependency-versions: [prefer-lowest, prefer-stable]
|
||||||
dependency-versions: 'lowest'
|
include:
|
||||||
- php-version: '5.4'
|
- php-version: 5.5
|
||||||
phpunit-version: 4
|
phpunit-version: 4
|
||||||
- php-version: '5.5'
|
|
||||||
phpunit-version: 4
|
|
||||||
- php-version: '5.6'
|
|
||||||
- php-version: '7.0'
|
|
||||||
- php-version: '7.1'
|
|
||||||
- php-version: '7.2'
|
|
||||||
- php-version: '7.3'
|
|
||||||
- php-version: '7.4'
|
|
||||||
- php-version: '8.0'
|
|
||||||
- php-version: '8.1'
|
|
||||||
- php-version: '8.1'
|
|
||||||
dependency-versions: 'highest'
|
|
||||||
composer-stability: 'dev'
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout project
|
- name: Checkout project
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Install and configure PHP
|
- name: Install and configure PHP
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: ${{ matrix.php-version }}
|
php-version: ${{ matrix.php-version }}
|
||||||
tools: composer:v2
|
tools: composer:v2
|
||||||
coverage: none
|
coverage: none
|
||||||
|
|
||||||
- name: Install phpunit
|
- name: Install phpunit
|
||||||
if: ${{ matrix.phpunit-version }}
|
if: ${{ matrix.phpunit-version }}
|
||||||
run: |
|
run: |
|
||||||
composer remove symfony/phpunit-bridge --dev
|
composer remove symfony/phpunit-bridge --dev
|
||||||
wget -O phpunit "https://phar.phpunit.de/phpunit-${{ matrix.phpunit-version }}.phar"
|
wget -O phpunit "https://phar.phpunit.de/phpunit-${{ matrix.phpunit-version }}.phar"
|
||||||
chmod +x phpunit
|
chmod +x phpunit
|
||||||
composer require "roave/security-advisories" dev-master --no-update
|
composer require "roave/security-advisories" dev-master --no-update
|
||||||
|
|
||||||
- name: Set composer stability
|
- name: Set composer stability
|
||||||
if: ${{ matrix.composer-stability }}
|
if: ${{ matrix.composer-stability }}
|
||||||
run: composer config minimum-stability ${{ matrix.composer-stability }}
|
run: composer config minimum-stability ${{ matrix.composer-stability }}
|
||||||
|
|
||||||
- name: Install composer dependencies
|
- name: Install composer dependencies
|
||||||
uses: ramsey/composer-install@v1
|
uses: ramsey/composer-install@v1
|
||||||
with:
|
with:
|
||||||
dependency-versions: ${{ matrix.dependency-versions }}
|
dependency-versions: ${{ matrix.dependency-versions }}
|
||||||
|
|
||||||
- name: Install ffmpeg
|
- name: Install ffmpeg
|
||||||
uses: FedericoCarboni/setup-ffmpeg@v1
|
uses: FedericoCarboni/setup-ffmpeg@v1
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
if: ${{ matrix.phpunit-version }}
|
run: |
|
||||||
run: |
|
if [ "$PHPUNIT_VERSION" ]; then
|
||||||
if [ "$PHPUNIT_VERSION" ]; then
|
./phpunit --verbose
|
||||||
./phpunit --verbose
|
else
|
||||||
else
|
./vendor/bin/simple-phpunit --verbose
|
||||||
./vendor/bin/simple-phpunit --verbose
|
fi;
|
||||||
fi;
|
|
||||||
|
|
|
||||||
|
|
@ -32,11 +32,11 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.3.9",
|
"php": ">=5.5.9",
|
||||||
"alchemy/binary-driver": "^1.5 || ~2.0.0 || ^5.0",
|
"alchemy/binary-driver": "^1.5 || ~2.0.0 || ^5.0",
|
||||||
"doctrine/cache": "^1.0|^2.0",
|
|
||||||
"evenement/evenement": "^3.0 || ^2.0 || ^1.0",
|
"evenement/evenement": "^3.0 || ^2.0 || ^1.0",
|
||||||
"neutron/temporary-filesystem": "^2.1.1 || ^3.0"
|
"neutron/temporary-filesystem": "^2.1.1 || ^3.0",
|
||||||
|
"symfony/cache": "^3.1 || ^4.0 || ^5.0 || ^6.0"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"php-ffmpeg/extras": "A compilation of common audio & video drivers for PHP-FFMpeg"
|
"php-ffmpeg/extras": "A compilation of common audio & video drivers for PHP-FFMpeg"
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
>
|
>
|
||||||
<php>
|
<php>
|
||||||
<env name="SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT" value="true"/>
|
<env name="SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT" value="true"/>
|
||||||
|
<env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled" />
|
||||||
</php>
|
</php>
|
||||||
|
|
||||||
<testsuites>
|
<testsuites>
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,9 @@
|
||||||
|
|
||||||
namespace FFMpeg;
|
namespace FFMpeg;
|
||||||
|
|
||||||
use Doctrine\Common\Cache\ArrayCache;
|
|
||||||
use Silex\Application;
|
use Silex\Application;
|
||||||
use Silex\ServiceProviderInterface;
|
use Silex\ServiceProviderInterface;
|
||||||
|
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
||||||
|
|
||||||
class FFMpegServiceProvider implements ServiceProviderInterface
|
class FFMpegServiceProvider implements ServiceProviderInterface
|
||||||
{
|
{
|
||||||
|
|
@ -44,7 +44,7 @@ class FFMpegServiceProvider implements ServiceProviderInterface
|
||||||
});
|
});
|
||||||
|
|
||||||
$app['ffprobe.cache'] = $app->share(function () {
|
$app['ffprobe.cache'] = $app->share(function () {
|
||||||
return new ArrayCache();
|
return new ArrayAdapter;
|
||||||
});
|
});
|
||||||
|
|
||||||
$app['ffmpeg.ffprobe'] = $app->share(function (Application $app) {
|
$app['ffmpeg.ffprobe'] = $app->share(function (Application $app) {
|
||||||
|
|
|
||||||
|
|
@ -13,27 +13,27 @@ namespace FFMpeg;
|
||||||
|
|
||||||
use Alchemy\BinaryDriver\ConfigurationInterface;
|
use Alchemy\BinaryDriver\ConfigurationInterface;
|
||||||
use Alchemy\BinaryDriver\Exception\ExecutionFailureException;
|
use Alchemy\BinaryDriver\Exception\ExecutionFailureException;
|
||||||
use Doctrine\Common\Cache\ArrayCache;
|
|
||||||
use Doctrine\Common\Cache\Cache;
|
|
||||||
use FFMpeg\Driver\FFProbeDriver;
|
use FFMpeg\Driver\FFProbeDriver;
|
||||||
|
use FFMpeg\Exception\InvalidArgumentException;
|
||||||
|
use FFMpeg\Exception\RuntimeException;
|
||||||
use FFMpeg\FFProbe\DataMapping\Format;
|
use FFMpeg\FFProbe\DataMapping\Format;
|
||||||
|
use FFMpeg\FFProbe\DataMapping\StreamCollection;
|
||||||
use FFMpeg\FFProbe\Mapper;
|
use FFMpeg\FFProbe\Mapper;
|
||||||
use FFMpeg\FFProbe\MapperInterface;
|
use FFMpeg\FFProbe\MapperInterface;
|
||||||
use FFMpeg\FFProbe\OptionsTester;
|
use FFMpeg\FFProbe\OptionsTester;
|
||||||
use FFMpeg\FFProbe\OptionsTesterInterface;
|
use FFMpeg\FFProbe\OptionsTesterInterface;
|
||||||
use FFMpeg\FFProbe\OutputParser;
|
use FFMpeg\FFProbe\OutputParser;
|
||||||
use FFMpeg\FFProbe\OutputParserInterface;
|
use FFMpeg\FFProbe\OutputParserInterface;
|
||||||
use FFMpeg\Exception\InvalidArgumentException;
|
use Psr\Cache\CacheItemPoolInterface;
|
||||||
use FFMpeg\Exception\RuntimeException;
|
|
||||||
use FFMpeg\FFProbe\DataMapping\StreamCollection;
|
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
||||||
|
|
||||||
class FFProbe
|
class FFProbe
|
||||||
{
|
{
|
||||||
const TYPE_STREAMS = 'streams';
|
const TYPE_STREAMS = 'streams';
|
||||||
const TYPE_FORMAT = 'format';
|
const TYPE_FORMAT = 'format';
|
||||||
|
|
||||||
/** @var Cache */
|
/** @var CacheItemPoolInterface */
|
||||||
private $cache;
|
private $cache;
|
||||||
/** @var OptionsTesterInterface */
|
/** @var OptionsTesterInterface */
|
||||||
private $optionsTester;
|
private $optionsTester;
|
||||||
|
|
@ -44,7 +44,7 @@ class FFProbe
|
||||||
/** @var MapperInterface */
|
/** @var MapperInterface */
|
||||||
private $mapper;
|
private $mapper;
|
||||||
|
|
||||||
public function __construct(FFProbeDriver $ffprobe, Cache $cache)
|
public function __construct(FFProbeDriver $ffprobe, CacheItemPoolInterface $cache)
|
||||||
{
|
{
|
||||||
$this->ffprobe = $ffprobe;
|
$this->ffprobe = $ffprobe;
|
||||||
$this->optionsTester = new OptionsTester($ffprobe, $cache);
|
$this->optionsTester = new OptionsTester($ffprobe, $cache);
|
||||||
|
|
@ -114,11 +114,11 @@ class FFProbe
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Cache $cache
|
* @param CacheItemPoolInterface $cache
|
||||||
*
|
*
|
||||||
* @return FFProbe
|
* @return FFProbe
|
||||||
*/
|
*/
|
||||||
public function setCache(Cache $cache)
|
public function setCache(CacheItemPoolInterface $cache)
|
||||||
{
|
{
|
||||||
$this->cache = $cache;
|
$this->cache = $cache;
|
||||||
|
|
||||||
|
|
@ -213,14 +213,14 @@ class FFProbe
|
||||||
*
|
*
|
||||||
* @param array|ConfigurationInterface $configuration
|
* @param array|ConfigurationInterface $configuration
|
||||||
* @param LoggerInterface $logger
|
* @param LoggerInterface $logger
|
||||||
* @param Cache $cache
|
* @param CacheItemPoolInterface $cache
|
||||||
*
|
*
|
||||||
* @return FFProbe
|
* @return FFProbe
|
||||||
*/
|
*/
|
||||||
public static function create($configuration = array(), LoggerInterface $logger = null, Cache $cache = null)
|
public static function create($configuration = array(), LoggerInterface $logger = null, CacheItemPoolInterface $cache = null)
|
||||||
{
|
{
|
||||||
if (null === $cache) {
|
if (null === $cache) {
|
||||||
$cache = new ArrayCache();
|
$cache = new ArrayAdapter();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new static(FFProbeDriver::create($configuration, $logger), $cache);
|
return new static(FFProbeDriver::create($configuration, $logger), $cache);
|
||||||
|
|
@ -228,10 +228,10 @@ class FFProbe
|
||||||
|
|
||||||
private function probe($pathfile, $command, $type, $allowJson = true)
|
private function probe($pathfile, $command, $type, $allowJson = true)
|
||||||
{
|
{
|
||||||
$id = sprintf('%s-%s', $command, $pathfile);
|
$id = md5(sprintf('%s-%s', $command, $pathfile));
|
||||||
|
|
||||||
if ($this->cache->contains($id)) {
|
if ($this->cache->hasItem($id)) {
|
||||||
return $this->cache->fetch($id);
|
return $this->cache->getItem($id)->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->optionsTester->has($command)) {
|
if (!$this->optionsTester->has($command)) {
|
||||||
|
|
@ -276,7 +276,9 @@ class FFProbe
|
||||||
|
|
||||||
$ret = $this->mapper->map($type, $data);
|
$ret = $this->mapper->map($type, $data);
|
||||||
|
|
||||||
$this->cache->save($id, $ret);
|
$cacheItem = $this->cache->getItem($id);
|
||||||
|
$cacheItem->set($ret);
|
||||||
|
$this->cache->save($cacheItem);
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,7 @@ abstract class AbstractData implements \Countable
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
#[\ReturnTypeWillChange]
|
||||||
public function count()
|
public function count()
|
||||||
{
|
{
|
||||||
return count($this->properties);
|
return count($this->properties);
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ class StreamCollection implements \Countable, \IteratorAggregate
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
#[\ReturnTypeWillChange]
|
||||||
public function count()
|
public function count()
|
||||||
{
|
{
|
||||||
return count($this->streams);
|
return count($this->streams);
|
||||||
|
|
@ -92,6 +93,7 @@ class StreamCollection implements \Countable, \IteratorAggregate
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
#[\ReturnTypeWillChange]
|
||||||
public function getIterator()
|
public function getIterator()
|
||||||
{
|
{
|
||||||
return new \ArrayIterator($this->streams);
|
return new \ArrayIterator($this->streams);
|
||||||
|
|
|
||||||
|
|
@ -12,18 +12,18 @@
|
||||||
namespace FFMpeg\FFProbe;
|
namespace FFMpeg\FFProbe;
|
||||||
|
|
||||||
use Alchemy\BinaryDriver\Exception\ExecutionFailureException;
|
use Alchemy\BinaryDriver\Exception\ExecutionFailureException;
|
||||||
use Doctrine\Common\Cache\Cache;
|
|
||||||
use FFMpeg\Driver\FFProbeDriver;
|
use FFMpeg\Driver\FFProbeDriver;
|
||||||
use FFMpeg\Exception\RuntimeException;
|
use FFMpeg\Exception\RuntimeException;
|
||||||
|
use Psr\Cache\CacheItemPoolInterface;
|
||||||
|
|
||||||
class OptionsTester implements OptionsTesterInterface
|
class OptionsTester implements OptionsTesterInterface
|
||||||
{
|
{
|
||||||
/** @var FFProbeDriver */
|
/** @var FFProbeDriver */
|
||||||
private $ffprobe;
|
private $ffprobe;
|
||||||
/** @var Cache */
|
/** @var CacheItemPoolInterface */
|
||||||
private $cache;
|
private $cache;
|
||||||
|
|
||||||
public function __construct(FFProbeDriver $ffprobe, Cache $cache)
|
public function __construct(FFProbeDriver $ffprobe, CacheItemPoolInterface $cache)
|
||||||
{
|
{
|
||||||
$this->ffprobe = $ffprobe;
|
$this->ffprobe = $ffprobe;
|
||||||
$this->cache = $cache;
|
$this->cache = $cache;
|
||||||
|
|
@ -34,17 +34,19 @@ class OptionsTester implements OptionsTesterInterface
|
||||||
*/
|
*/
|
||||||
public function has($name)
|
public function has($name)
|
||||||
{
|
{
|
||||||
$id = sprintf('option-%s', $name);
|
$id = md5(sprintf('option-%s', $name));
|
||||||
|
|
||||||
if ($this->cache->contains($id)) {
|
if ($this->cache->hasItem($id)) {
|
||||||
return $this->cache->fetch($id);
|
return $this->cache->getItem($id)->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = $this->retrieveHelpOutput();
|
$output = $this->retrieveHelpOutput();
|
||||||
|
|
||||||
$ret = (bool) preg_match('/^'.$name.'/m', $output);
|
$ret = (bool) preg_match('/^'.$name.'/m', $output);
|
||||||
|
|
||||||
$this->cache->save($id, $ret);
|
$cacheItem = $this->cache->getItem($id);
|
||||||
|
$cacheItem->set($ret);
|
||||||
|
$this->cache->save($cacheItem);
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
@ -53,8 +55,8 @@ class OptionsTester implements OptionsTesterInterface
|
||||||
{
|
{
|
||||||
$id = 'help';
|
$id = 'help';
|
||||||
|
|
||||||
if ($this->cache->contains($id)) {
|
if ($this->cache->hasItem($id)) {
|
||||||
return $this->cache->fetch($id);
|
return $this->cache->getItem($id)->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -63,7 +65,9 @@ class OptionsTester implements OptionsTesterInterface
|
||||||
throw new RuntimeException('Your FFProbe version is too old and does not support `-help` option, please upgrade.', $e->getCode(), $e);
|
throw new RuntimeException('Your FFProbe version is too old and does not support `-help` option, please upgrade.', $e->getCode(), $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->cache->save($id, $output);
|
$cacheItem = $this->cache->getItem($id);
|
||||||
|
$cacheItem->set($output);
|
||||||
|
$this->cache->save($cacheItem);
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ class FiltersCollection implements \Countable, \IteratorAggregate
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
#[\ReturnTypeWillChange]
|
||||||
public function count()
|
public function count()
|
||||||
{
|
{
|
||||||
if (0 === count($this->filters)) {
|
if (0 === count($this->filters)) {
|
||||||
|
|
@ -44,6 +45,7 @@ class FiltersCollection implements \Countable, \IteratorAggregate
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
#[\ReturnTypeWillChange]
|
||||||
public function getIterator()
|
public function getIterator()
|
||||||
{
|
{
|
||||||
if (null === $this->sorted) {
|
if (null === $this->sorted) {
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,9 @@
|
||||||
|
|
||||||
namespace Tests\FFMpeg\Unit\FFProbe;
|
namespace Tests\FFMpeg\Unit\FFProbe;
|
||||||
|
|
||||||
use Tests\FFMpeg\Unit\TestCase;
|
|
||||||
use FFMpeg\FFProbe\OptionsTester;
|
use FFMpeg\FFProbe\OptionsTester;
|
||||||
|
use Symfony\Component\Cache\CacheItem;
|
||||||
|
use Tests\FFMpeg\Unit\TestCase;
|
||||||
|
|
||||||
class OptionsTesterTest extends TestCase
|
class OptionsTesterTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
@ -36,11 +37,12 @@ class OptionsTesterTest extends TestCase
|
||||||
{
|
{
|
||||||
$cache = $this->getCacheMock();
|
$cache = $this->getCacheMock();
|
||||||
|
|
||||||
$cache->expects($this->never())
|
$cache->expects($this->exactly(2))
|
||||||
->method('fetch');
|
->method('getItem')
|
||||||
|
->will($this->returnValue(new CacheItem));
|
||||||
|
|
||||||
$cache->expects($this->exactly(2))
|
$cache->expects($this->exactly(2))
|
||||||
->method('contains')
|
->method('hasItem')
|
||||||
->will($this->returnValue(false));
|
->will($this->returnValue(false));
|
||||||
|
|
||||||
$cache->expects($this->exactly(2))
|
$cache->expects($this->exactly(2))
|
||||||
|
|
@ -73,16 +75,22 @@ class OptionsTesterTest extends TestCase
|
||||||
{
|
{
|
||||||
$cache = $this->getCacheMock();
|
$cache = $this->getCacheMock();
|
||||||
|
|
||||||
$cache->expects($this->once())
|
$cacheItem = new CacheItem;
|
||||||
->method('fetch')
|
$cacheItem->set($data);
|
||||||
->will($this->returnValue($data));
|
|
||||||
|
|
||||||
$cache->expects($this->exactly(2))
|
$cache->expects($this->exactly(2))
|
||||||
->method('contains')
|
->method('getItem')
|
||||||
|
->willReturnOnConsecutiveCalls(
|
||||||
|
$this->returnValue($cacheItem),
|
||||||
|
$this->returnValue(new CacheItem)
|
||||||
|
);
|
||||||
|
|
||||||
|
$cache->expects($this->exactly(2))
|
||||||
|
->method('hasItem')
|
||||||
->willReturnOnConsecutiveCalls(
|
->willReturnOnConsecutiveCalls(
|
||||||
$this->returnValue(false),
|
$this->returnValue(false),
|
||||||
$this->returnValue(true));
|
$this->returnValue(true)
|
||||||
|
);
|
||||||
$cache->expects($this->once())
|
$cache->expects($this->once())
|
||||||
->method('save');
|
->method('save');
|
||||||
|
|
||||||
|
|
@ -101,14 +109,17 @@ class OptionsTesterTest extends TestCase
|
||||||
{
|
{
|
||||||
$cache = $this->getCacheMock();
|
$cache = $this->getCacheMock();
|
||||||
|
|
||||||
$cache->expects($this->once())
|
$cacheItem = new CacheItem();
|
||||||
->method('fetch')
|
$cacheItem->set($isPresent);
|
||||||
->with('option-' . $optionName)
|
|
||||||
->will($this->returnValue($isPresent));
|
|
||||||
|
|
||||||
$cache->expects($this->once())
|
$cache->expects($this->once())
|
||||||
->method('contains')
|
->method('getItem')
|
||||||
->with('option-' . $optionName)
|
->with(md5('option-' . $optionName))
|
||||||
|
->will($this->returnValue($cacheItem));
|
||||||
|
|
||||||
|
$cache->expects($this->once())
|
||||||
|
->method('hasItem')
|
||||||
|
->with(md5('option-' . $optionName))
|
||||||
->will($this->returnValue(true));
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
$ffprobe = $this->getFFProbeDriverMock();
|
$ffprobe = $this->getFFProbeDriverMock();
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,11 @@
|
||||||
|
|
||||||
namespace Tests\FFMpeg\Unit;
|
namespace Tests\FFMpeg\Unit;
|
||||||
|
|
||||||
use FFMpeg\FFProbe;
|
|
||||||
use Symfony\Component\Process\ExecutableFinder;
|
|
||||||
use Alchemy\BinaryDriver\ConfigurationInterface;
|
|
||||||
use Alchemy\BinaryDriver\Configuration;
|
use Alchemy\BinaryDriver\Configuration;
|
||||||
|
use Alchemy\BinaryDriver\ConfigurationInterface;
|
||||||
|
use FFMpeg\FFProbe;
|
||||||
|
use Symfony\Component\Cache\CacheItem;
|
||||||
|
use Symfony\Component\Process\ExecutableFinder;
|
||||||
|
|
||||||
class FFProbeTest extends TestCase
|
class FFProbeTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
@ -100,13 +101,14 @@ class FFProbeTest extends TestCase
|
||||||
|
|
||||||
$cache = $this->getCacheMock();
|
$cache = $this->getCacheMock();
|
||||||
$cache->expects($this->once())
|
$cache->expects($this->once())
|
||||||
->method('contains')
|
->method('hasItem')
|
||||||
->will($this->returnValue(false));
|
->will($this->returnValue(false));
|
||||||
$cache->expects($this->never())
|
$cache->expects($this->once())
|
||||||
->method('fetch');
|
->method('getItem')
|
||||||
|
->will($this->returnValue(new CacheItem));
|
||||||
$cache->expects($this->once())
|
$cache->expects($this->once())
|
||||||
->method('save')
|
->method('save')
|
||||||
->with($this->anything(), $output);
|
->with($this->anything());
|
||||||
|
|
||||||
$driver = $this->getFFProbeDriverMock();
|
$driver = $this->getFFProbeDriverMock();
|
||||||
$driver->expects($this->once())
|
$driver->expects($this->once())
|
||||||
|
|
@ -160,10 +162,11 @@ class FFProbeTest extends TestCase
|
||||||
|
|
||||||
$cache = $this->getCacheMock();
|
$cache = $this->getCacheMock();
|
||||||
$cache->expects($this->exactly(2))
|
$cache->expects($this->exactly(2))
|
||||||
->method('contains')
|
->method('hasItem')
|
||||||
->will($this->returnValue(false));
|
->will($this->returnValue(false));
|
||||||
$cache->expects($this->never())
|
$cache->expects($this->once())
|
||||||
->method('fetch');
|
->method('getItem')
|
||||||
|
->will($this->returnValue(new CacheItem));
|
||||||
|
|
||||||
$driver = $this->getFFProbeDriverMock();
|
$driver = $this->getFFProbeDriverMock();
|
||||||
$driver->expects($this->exactly(2))
|
$driver->expects($this->exactly(2))
|
||||||
|
|
@ -205,13 +208,16 @@ class FFProbeTest extends TestCase
|
||||||
|
|
||||||
$tester = $this->getFFProbeOptionsTesterMock();
|
$tester = $this->getFFProbeOptionsTesterMock();
|
||||||
|
|
||||||
|
$cacheItem = new CacheItem;
|
||||||
|
$cacheItem->set($output);
|
||||||
|
|
||||||
$cache = $this->getCacheMock();
|
$cache = $this->getCacheMock();
|
||||||
$cache->expects($this->once())
|
$cache->expects($this->once())
|
||||||
->method('contains')
|
->method('hasItem')
|
||||||
->will($this->returnValue(true));
|
->will($this->returnValue(true));
|
||||||
$cache->expects($this->once())
|
$cache->expects($this->once())
|
||||||
->method('fetch')
|
->method('getItem')
|
||||||
->will($this->returnValue($output));
|
->will($this->returnValue($cacheItem));
|
||||||
$cache->expects($this->never())
|
$cache->expects($this->never())
|
||||||
->method('save');
|
->method('save');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ class TestCase extends BaseTestCase
|
||||||
|
|
||||||
public function getCacheMock()
|
public function getCacheMock()
|
||||||
{
|
{
|
||||||
return $this->getMockBuilder('Doctrine\Common\Cache\Cache')->getMock();
|
return $this->getMockBuilder('Psr\Cache\CacheItemPoolInterface')->getMock();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTimeCodeMock()
|
public function getTimeCodeMock()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue