Permalink
Browse files

Drop support for PHP 5.4 and 5.5

  • Loading branch information...
Art4 committed Oct 10, 2017
1 parent d771e43 commit 467dc1ea4c64b5fc1b9f24a517a5ab8c3ee08152
View
@@ -2,8 +2,6 @@ language: php
matrix:
include:
- php: 5.4
- php: 5.5
- php: 5.6
- php: 7.0
- php: 7.1
View
@@ -17,13 +17,13 @@
"sort-packages": true
},
"require": {
"php": "^5.4 || ^7.0",
"php": "^5.6 || ^7.0",
"ext-curl": "*"
},
"require-dev": {
"guzzlehttp/psr7": "^1.4",
"mikey179/vfsStream": "^1.6",
"phpunit/phpunit": "^4.8.35 || ^6.0",
"phpunit/phpunit": "^5.4.3 || ^6.0",
"psr/container": "^1.0",
"psr/http-message": "^1.0",
"psr/log": "^1.0",
@@ -20,6 +20,8 @@
namespace YoutubeDownloader\Tests\Fixture\Cache;
use YoutubeDownloader\Cache\InvalidArgumentException;
/**
* Trait that provides data for tests
*/
@@ -30,7 +32,7 @@
*/
public function InvalidKeyProvider()
{
$exception_name = '\\YoutubeDownloader\\Cache\\InvalidArgumentException';
$exception_name = InvalidArgumentException::class;
return [
[null, $exception_name, 'Cache key must be string, "NULL" given'],
View
@@ -20,73 +20,4 @@
namespace YoutubeDownloader\Tests\Fixture;
class TestCase extends \PHPUnit\Framework\TestCase
{
private $lastExpectedException;
/**
* Returns a test double for the specified class.
*
* Shim for PHPUnit 4
*
* @param string $originalClassName
* @return PHPUnit_Framework_MockObject_MockObject
* @throws Exception
*/
protected function createMock($originalClassName)
{
if (is_callable('parent::createMock'))
{
return parent::createMock($originalClassName);
}
return $this->getMockBuilder($originalClassName)
->disableOriginalConstructor()
->disableOriginalClone()
->disableArgumentCloning()
->getMock();
}
/**
*
* Shim for PHPUnit 4
* @param string $exception
*/
public function expectException($exception)
{
if (is_callable('parent::expectException'))
{
return parent::expectException($exception);
}
// Cache the exception name
$this->lastExpectedException = $exception;
}
/**
* Shim for PHPUnit 4
*
* @param string $message
*
* @throws Exception
*/
public function expectExceptionMessage($message)
{
if (is_callable('parent::expectExceptionMessage'))
{
return parent::expectExceptionMessage($message);
}
if ( $this->lastExpectedException === null )
{
$this->lastExpectedException = '\\Exception';
}
$this->setExpectedException(
$this->lastExpectedException,
$message
);
$this->expectedExceptionMessage = null;
}
}
class TestCase extends \PHPUnit\Framework\TestCase {}
@@ -21,7 +21,10 @@
namespace YoutubeDownloader\Tests\Unit\Application;
use YoutubeDownloader\Application\App;
use YoutubeDownloader\Application\Controller;
use YoutubeDownloader\Application\ControllerFactory;
use YoutubeDownloader\Container\Container;
use YoutubeDownloader\Logger\Logger;
use YoutubeDownloader\Tests\Fixture\TestCase;
class AppTest extends TestCase
@@ -31,9 +34,9 @@ class AppTest extends TestCase
*/
public function getContainer()
{
$logger = $this->createMock('\\YoutubeDownloader\\Logger\\Logger');
$logger = $this->createMock(Logger::class);
$container = $this->createMock('\\YoutubeDownloader\\Container\\Container');
$container = $this->createMock(Container::class);
$container->method('get')->with('logger')->willReturn($logger);
$app = new App($container);
@@ -46,9 +49,9 @@ public function getContainer()
*/
public function getVersion()
{
$logger = $this->createMock('\\YoutubeDownloader\\Logger\\Logger');
$logger = $this->createMock(Logger::class);
$container = $this->createMock('\\YoutubeDownloader\\Container\\Container');
$container = $this->createMock(Container::class);
$container->method('get')->with('logger')->willReturn($logger);
$app = new App($container);
@@ -61,21 +64,17 @@ public function getVersion()
*/
public function runWithRoute()
{
$controller = $this->createMock(
'\\YoutubeDownloader\\Application\\Controller'
);
$controller = $this->createMock(Controller::class);
$controller->expects($this->once())->method('execute');
$factory = $this->createMock(
'\\YoutubeDownloader\\Application\\ControllerFactory'
);
$factory = $this->createMock(ControllerFactory::class);
$factory->expects($this->once())
->method('make')
->willReturn($controller);
$logger = $this->createMock('\\YoutubeDownloader\\Logger\\Logger');
$logger = $this->createMock(Logger::class);
$container = $this->createMock('\\YoutubeDownloader\\Container\\Container');
$container = $this->createMock(Container::class);
$container->method('get')->will($this->returnValueMap([
['controller_factory', $factory],
['logger', $logger],
@@ -20,7 +20,12 @@
namespace YoutubeDownloader\Tests\Unit\Application;
use Exception;
use YoutubeDownloader\Application\App;
use YoutubeDownloader\Application\Controller;
use YoutubeDownloader\Application\ControllerFactory;
use YoutubeDownloader\Container\Container;
use YoutubeDownloader\Logger\Logger;
use YoutubeDownloader\Tests\Fixture\TestCase;
class ControllerFactoryTest extends TestCase
@@ -30,18 +35,18 @@ class ControllerFactoryTest extends TestCase
*/
public function make()
{
$logger = $this->createMock('\\YoutubeDownloader\\Logger\\Logger');
$logger = $this->createMock(Logger::class);
$container = $this->createMock('\\YoutubeDownloader\\Container\\Container');
$container = $this->createMock(Container::class);
$container->method('get')->with('logger')->willReturn($logger);
$app = $this->createMock('\\YoutubeDownloader\\Application\\App');
$app = $this->createMock(App::class);
$app->method('getContainer')->willReturn($container);
$factory = new ControllerFactory;
$this->assertInstanceOf(
'\\YoutubeDownloader\\Application\\Controller',
Controller::class,
$factory->make('index', $app)
);
}
@@ -51,15 +56,15 @@ public function make()
*/
public function makeThrowsException()
{
$app = $this->createMock('\\YoutubeDownloader\\Application\\App');
$app = $this->createMock(App::class);
$factory = new ControllerFactory;
$this->expectException('\\Exception');
$this->expectException(Exception::class);
$this->expectExceptionMessage('No controller was found for route "fail"');
$this->assertInstanceOf(
'\\YoutubeDownloader\\Application\\Controller',
Controller::class,
$factory->make('fail', $app)
);
}
@@ -33,18 +33,18 @@ class ImageControllerTest extends \YoutubeDownloader\Tests\Fixture\TestCase
*/
public function validateVideoId($str, $expected)
{
$logger = $this->createMock('\\YoutubeDownloader\\Logger\\Logger');
$logger = $this->createMock(Logger::class);
$container = $this->createMock('\\YoutubeDownloader\\Container\\Container');
$container = $this->createMock(Container::class);
$container->method('get')->with('logger')->willReturn($logger);
$app = $this->createMock('\\YoutubeDownloader\\Application\\App');
$app = $this->createMock(App::class);
$app->method('getContainer')->willReturn($container);
$controller = new ImageController($app);
// set validateVideoId() accessible
$method = new \ReflectionMethod('\\YoutubeDownloader\\Application\\ImageController', 'validateVideoId');
$method = new \ReflectionMethod(ImageController::class, 'validateVideoId');
$method->setAccessible(true);
$this->assertSame($expected, $method->invoke($controller, $str));
@@ -22,6 +22,9 @@
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamDirectory;
use Psr\SimpleCache\CacheInterface;
use YoutubeDownloader\Cache\Cache;
use YoutubeDownloader\Cache\CacheException;
use YoutubeDownloader\Cache\FileCache;
use YoutubeDownloader\Tests\Fixture\Cache\DataProviderTrait;
use YoutubeDownloader\Tests\Fixture\Cache\Psr16CacheAdapter;
@@ -39,7 +42,7 @@ public function createFromDirectory()
$root = vfsStream::setup('cache');
$this->assertInstanceOf(
'\\YoutubeDownloader\\Cache\\FileCache',
FileCache::class,
FileCache::createFromDirectory($root->url())
);
}
@@ -55,8 +58,8 @@ public function isPsr16Compatible()
$adapter = new Psr16CacheAdapter($cache);
$this->assertInstanceOf('\\Psr\\SimpleCache\\CacheInterface', $adapter);
$this->assertInstanceOf('\\YoutubeDownloader\\Cache\\Cache', $adapter);
$this->assertInstanceOf(CacheInterface::class, $adapter);
$this->assertInstanceOf(Cache::class, $adapter);
}
/**
@@ -66,7 +69,7 @@ public function createFromDirectoryThrowsExceptionIfFolderNotExists()
{
$root = vfsStream::setup('cache');
$this->expectException('\\YoutubeDownloader\\Cache\\CacheException');
$this->expectException(CacheException::class);
$this->expectExceptionMessage('cache directory "vfs://not_existing" does not exist.');
FileCache::createFromDirectory('vfs://not_existing');
@@ -80,7 +83,7 @@ public function createFromDirectoryThrowsExceptionIfFolderIsNotDirectory()
$root = vfsStream::setup('cache');
vfsStream::newFile('file', 0000)->at($root);
$this->expectException('\\YoutubeDownloader\\Cache\\CacheException');
$this->expectException(CacheException::class);
$this->expectExceptionMessage('cache directory "vfs://cache/file" is not a directory.');
FileCache::createFromDirectory('vfs://cache/file');
@@ -93,7 +96,7 @@ public function createFromDirectoryThrowsExceptionIfFolderNotReadable()
{
$root = vfsStream::setup('cache', 0000);
$this->expectException('\\YoutubeDownloader\\Cache\\CacheException');
$this->expectException(CacheException::class);
$this->expectExceptionMessage('cache directory "vfs://cache" is not readable.');
FileCache::createFromDirectory($root->url());
@@ -106,7 +109,7 @@ public function createFromDirectoryThrowsExceptionIfFolderNotWritable()
{
$root = vfsStream::setup('cache', 0400);
$this->expectException('\\YoutubeDownloader\\Cache\\CacheException');
$this->expectException(CacheException::class);
$this->expectExceptionMessage('cache directory "vfs://cache" is not writable.');
FileCache::createFromDirectory($root->url());
@@ -20,6 +20,10 @@
namespace YoutubeDownloader\Tests\Unit\Container;
use Psr\Container\ContainerInterface;
use YoutubeDownloader\Container\Container;
use YoutubeDownloader\Container\ContainerException;
use YoutubeDownloader\Container\NotFoundException;
use YoutubeDownloader\Container\SimpleContainer;
use YoutubeDownloader\Tests\Fixture\TestCase;
use YoutubeDownloader\Tests\Fixture\Container\Psr11ContainerAdapter;
@@ -33,7 +37,7 @@ public function implementsContainer()
{
$container = new SimpleContainer();
$this->assertInstanceOf('\\YoutubeDownloader\\Container\\Container', $container);
$this->assertInstanceOf(Container::class, $container);
}
/**
@@ -45,8 +49,8 @@ public function isPsr11Compatible()
$adapter = new Psr11ContainerAdapter($container);
$this->assertInstanceOf('\\Psr\\Container\\ContainerInterface', $adapter);
$this->assertInstanceOf('\\YoutubeDownloader\\Container\\Container', $adapter);
$this->assertInstanceOf(ContainerInterface::class, $adapter);
$this->assertInstanceOf(Container::class, $adapter);
}
/**
@@ -57,7 +61,7 @@ public function testSetterAndGetterThrowsExceptionWithoutClosure($id, $value)
{
$container = new SimpleContainer();
$this->expectException('\\YoutubeDownloader\\Container\\ContainerException');
$this->expectException(ContainerException::class);
$this->expectExceptionMessage('Second argument ($value) must be a Closure or a string as alias to an existing entry.');
$container->set($id, $value);
@@ -124,7 +128,7 @@ public function getThrowsNotFoundException()
{
$container = new SimpleContainer();
$this->expectException('\\YoutubeDownloader\\Container\\NotFoundException');
$this->expectException(NotFoundException::class);
$this->expectExceptionMessage('Entry "foo" don\'t exists in the container');
$container->get('foo');
@@ -20,6 +20,8 @@
namespace YoutubeDownloader\Tests\Unit\Cache;
use Psr\Http\Message\MessageInterface;
use YoutubeDownloader\Http\Message\Message as IMessage;
use YoutubeDownloader\Http\MessageTrait;
use YoutubeDownloader\Tests\Fixture\Http\Message;
use YoutubeDownloader\Tests\Fixture\Http\Psr7MessageAdapter;
@@ -36,8 +38,8 @@ public function isPsr7Compatible()
$adapter = new Psr7MessageAdapter($message);
$this->assertInstanceOf('\\Psr\\Http\\Message\\MessageInterface', $adapter);
$this->assertInstanceOf('\\YoutubeDownloader\\Http\\Message\\Message', $adapter);
$this->assertInstanceOf(MessageInterface::class, $adapter);
$this->assertInstanceOf(IMessage::class, $adapter);
}
/**
Oops, something went wrong.

0 comments on commit 467dc1e

Please sign in to comment.