Skip to content
This repository has been archived by the owner on Jul 12, 2020. It is now read-only.

Commit

Permalink
Drop support for PHP 5.4 and 5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Art4 committed Oct 10, 2017
1 parent d771e43 commit 467dc1e
Show file tree
Hide file tree
Showing 20 changed files with 105 additions and 153 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Expand Up @@ -2,8 +2,6 @@ language: php


matrix: matrix:
include: include:
- php: 5.4
- php: 5.5
- php: 5.6 - php: 5.6
- php: 7.0 - php: 7.0
- php: 7.1 - php: 7.1
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -17,13 +17,13 @@
"sort-packages": true "sort-packages": true
}, },
"require": { "require": {
"php": "^5.4 || ^7.0", "php": "^5.6 || ^7.0",
"ext-curl": "*" "ext-curl": "*"
}, },
"require-dev": { "require-dev": {
"guzzlehttp/psr7": "^1.4", "guzzlehttp/psr7": "^1.4",
"mikey179/vfsStream": "^1.6", "mikey179/vfsStream": "^1.6",
"phpunit/phpunit": "^4.8.35 || ^6.0", "phpunit/phpunit": "^5.4.3 || ^6.0",
"psr/container": "^1.0", "psr/container": "^1.0",
"psr/http-message": "^1.0", "psr/http-message": "^1.0",
"psr/log": "^1.0", "psr/log": "^1.0",
Expand Down
4 changes: 3 additions & 1 deletion tests/Fixture/Cache/DataProviderTrait.php
Expand Up @@ -20,6 +20,8 @@


namespace YoutubeDownloader\Tests\Fixture\Cache; namespace YoutubeDownloader\Tests\Fixture\Cache;


use YoutubeDownloader\Cache\InvalidArgumentException;

/** /**
* Trait that provides data for tests * Trait that provides data for tests
*/ */
Expand All @@ -30,7 +32,7 @@ trait DataProviderTrait
*/ */
public function InvalidKeyProvider() public function InvalidKeyProvider()
{ {
$exception_name = '\\YoutubeDownloader\\Cache\\InvalidArgumentException'; $exception_name = InvalidArgumentException::class;


return [ return [
[null, $exception_name, 'Cache key must be string, "NULL" given'], [null, $exception_name, 'Cache key must be string, "NULL" given'],
Expand Down
71 changes: 1 addition & 70 deletions tests/Fixture/TestCase.php
Expand Up @@ -20,73 +20,4 @@


namespace YoutubeDownloader\Tests\Fixture; namespace YoutubeDownloader\Tests\Fixture;


class TestCase extends \PHPUnit\Framework\TestCase 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;
}
}
23 changes: 11 additions & 12 deletions tests/Unit/Application/AppTest.php
Expand Up @@ -21,7 +21,10 @@
namespace YoutubeDownloader\Tests\Unit\Application; namespace YoutubeDownloader\Tests\Unit\Application;


use YoutubeDownloader\Application\App; use YoutubeDownloader\Application\App;
use YoutubeDownloader\Application\Controller;
use YoutubeDownloader\Application\ControllerFactory;
use YoutubeDownloader\Container\Container; use YoutubeDownloader\Container\Container;
use YoutubeDownloader\Logger\Logger;
use YoutubeDownloader\Tests\Fixture\TestCase; use YoutubeDownloader\Tests\Fixture\TestCase;


class AppTest extends TestCase class AppTest extends TestCase
Expand All @@ -31,9 +34,9 @@ class AppTest extends TestCase
*/ */
public function getContainer() 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); $container->method('get')->with('logger')->willReturn($logger);


$app = new App($container); $app = new App($container);
Expand All @@ -46,9 +49,9 @@ public function getContainer()
*/ */
public function getVersion() 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); $container->method('get')->with('logger')->willReturn($logger);


$app = new App($container); $app = new App($container);
Expand All @@ -61,21 +64,17 @@ public function getVersion()
*/ */
public function runWithRoute() public function runWithRoute()
{ {
$controller = $this->createMock( $controller = $this->createMock(Controller::class);
'\\YoutubeDownloader\\Application\\Controller'
);
$controller->expects($this->once())->method('execute'); $controller->expects($this->once())->method('execute');


$factory = $this->createMock( $factory = $this->createMock(ControllerFactory::class);
'\\YoutubeDownloader\\Application\\ControllerFactory'
);
$factory->expects($this->once()) $factory->expects($this->once())
->method('make') ->method('make')
->willReturn($controller); ->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([ $container->method('get')->will($this->returnValueMap([
['controller_factory', $factory], ['controller_factory', $factory],
['logger', $logger], ['logger', $logger],
Expand Down
19 changes: 12 additions & 7 deletions tests/Unit/Application/ControllerFactoryTest.php
Expand Up @@ -20,7 +20,12 @@


namespace YoutubeDownloader\Tests\Unit\Application; namespace YoutubeDownloader\Tests\Unit\Application;


use Exception;
use YoutubeDownloader\Application\App;
use YoutubeDownloader\Application\Controller;
use YoutubeDownloader\Application\ControllerFactory; use YoutubeDownloader\Application\ControllerFactory;
use YoutubeDownloader\Container\Container;
use YoutubeDownloader\Logger\Logger;
use YoutubeDownloader\Tests\Fixture\TestCase; use YoutubeDownloader\Tests\Fixture\TestCase;


class ControllerFactoryTest extends TestCase class ControllerFactoryTest extends TestCase
Expand All @@ -30,18 +35,18 @@ class ControllerFactoryTest extends TestCase
*/ */
public function make() 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); $container->method('get')->with('logger')->willReturn($logger);


$app = $this->createMock('\\YoutubeDownloader\\Application\\App'); $app = $this->createMock(App::class);
$app->method('getContainer')->willReturn($container); $app->method('getContainer')->willReturn($container);


$factory = new ControllerFactory; $factory = new ControllerFactory;


$this->assertInstanceOf( $this->assertInstanceOf(
'\\YoutubeDownloader\\Application\\Controller', Controller::class,
$factory->make('index', $app) $factory->make('index', $app)
); );
} }
Expand All @@ -51,15 +56,15 @@ public function make()
*/ */
public function makeThrowsException() public function makeThrowsException()
{ {
$app = $this->createMock('\\YoutubeDownloader\\Application\\App'); $app = $this->createMock(App::class);


$factory = new ControllerFactory; $factory = new ControllerFactory;


$this->expectException('\\Exception'); $this->expectException(Exception::class);
$this->expectExceptionMessage('No controller was found for route "fail"'); $this->expectExceptionMessage('No controller was found for route "fail"');


$this->assertInstanceOf( $this->assertInstanceOf(
'\\YoutubeDownloader\\Application\\Controller', Controller::class,
$factory->make('fail', $app) $factory->make('fail', $app)
); );
} }
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/Application/ImageControllerTest.php
Expand Up @@ -33,18 +33,18 @@ class ImageControllerTest extends \YoutubeDownloader\Tests\Fixture\TestCase
*/ */
public function validateVideoId($str, $expected) 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); $container->method('get')->with('logger')->willReturn($logger);


$app = $this->createMock('\\YoutubeDownloader\\Application\\App'); $app = $this->createMock(App::class);
$app->method('getContainer')->willReturn($container); $app->method('getContainer')->willReturn($container);


$controller = new ImageController($app); $controller = new ImageController($app);


// set validateVideoId() accessible // set validateVideoId() accessible
$method = new \ReflectionMethod('\\YoutubeDownloader\\Application\\ImageController', 'validateVideoId'); $method = new \ReflectionMethod(ImageController::class, 'validateVideoId');
$method->setAccessible(true); $method->setAccessible(true);


$this->assertSame($expected, $method->invoke($controller, $str)); $this->assertSame($expected, $method->invoke($controller, $str));
Expand Down
17 changes: 10 additions & 7 deletions tests/Unit/Cache/FileCacheTest.php
Expand Up @@ -22,6 +22,9 @@


use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamDirectory; use org\bovigo\vfs\vfsStreamDirectory;
use Psr\SimpleCache\CacheInterface;
use YoutubeDownloader\Cache\Cache;
use YoutubeDownloader\Cache\CacheException;
use YoutubeDownloader\Cache\FileCache; use YoutubeDownloader\Cache\FileCache;
use YoutubeDownloader\Tests\Fixture\Cache\DataProviderTrait; use YoutubeDownloader\Tests\Fixture\Cache\DataProviderTrait;
use YoutubeDownloader\Tests\Fixture\Cache\Psr16CacheAdapter; use YoutubeDownloader\Tests\Fixture\Cache\Psr16CacheAdapter;
Expand All @@ -39,7 +42,7 @@ public function createFromDirectory()
$root = vfsStream::setup('cache'); $root = vfsStream::setup('cache');


$this->assertInstanceOf( $this->assertInstanceOf(
'\\YoutubeDownloader\\Cache\\FileCache', FileCache::class,
FileCache::createFromDirectory($root->url()) FileCache::createFromDirectory($root->url())
); );
} }
Expand All @@ -55,8 +58,8 @@ public function isPsr16Compatible()


$adapter = new Psr16CacheAdapter($cache); $adapter = new Psr16CacheAdapter($cache);


$this->assertInstanceOf('\\Psr\\SimpleCache\\CacheInterface', $adapter); $this->assertInstanceOf(CacheInterface::class, $adapter);
$this->assertInstanceOf('\\YoutubeDownloader\\Cache\\Cache', $adapter); $this->assertInstanceOf(Cache::class, $adapter);
} }


/** /**
Expand All @@ -66,7 +69,7 @@ public function createFromDirectoryThrowsExceptionIfFolderNotExists()
{ {
$root = vfsStream::setup('cache'); $root = vfsStream::setup('cache');


$this->expectException('\\YoutubeDownloader\\Cache\\CacheException'); $this->expectException(CacheException::class);
$this->expectExceptionMessage('cache directory "vfs://not_existing" does not exist.'); $this->expectExceptionMessage('cache directory "vfs://not_existing" does not exist.');


FileCache::createFromDirectory('vfs://not_existing'); FileCache::createFromDirectory('vfs://not_existing');
Expand All @@ -80,7 +83,7 @@ public function createFromDirectoryThrowsExceptionIfFolderIsNotDirectory()
$root = vfsStream::setup('cache'); $root = vfsStream::setup('cache');
vfsStream::newFile('file', 0000)->at($root); 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.'); $this->expectExceptionMessage('cache directory "vfs://cache/file" is not a directory.');


FileCache::createFromDirectory('vfs://cache/file'); FileCache::createFromDirectory('vfs://cache/file');
Expand All @@ -93,7 +96,7 @@ public function createFromDirectoryThrowsExceptionIfFolderNotReadable()
{ {
$root = vfsStream::setup('cache', 0000); $root = vfsStream::setup('cache', 0000);


$this->expectException('\\YoutubeDownloader\\Cache\\CacheException'); $this->expectException(CacheException::class);
$this->expectExceptionMessage('cache directory "vfs://cache" is not readable.'); $this->expectExceptionMessage('cache directory "vfs://cache" is not readable.');


FileCache::createFromDirectory($root->url()); FileCache::createFromDirectory($root->url());
Expand All @@ -106,7 +109,7 @@ public function createFromDirectoryThrowsExceptionIfFolderNotWritable()
{ {
$root = vfsStream::setup('cache', 0400); $root = vfsStream::setup('cache', 0400);


$this->expectException('\\YoutubeDownloader\\Cache\\CacheException'); $this->expectException(CacheException::class);
$this->expectExceptionMessage('cache directory "vfs://cache" is not writable.'); $this->expectExceptionMessage('cache directory "vfs://cache" is not writable.');


FileCache::createFromDirectory($root->url()); FileCache::createFromDirectory($root->url());
Expand Down
14 changes: 9 additions & 5 deletions tests/Unit/Container/SimpleContainerTest.php
Expand Up @@ -20,6 +20,10 @@


namespace YoutubeDownloader\Tests\Unit\Container; 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\Container\SimpleContainer;
use YoutubeDownloader\Tests\Fixture\TestCase; use YoutubeDownloader\Tests\Fixture\TestCase;
use YoutubeDownloader\Tests\Fixture\Container\Psr11ContainerAdapter; use YoutubeDownloader\Tests\Fixture\Container\Psr11ContainerAdapter;
Expand All @@ -33,7 +37,7 @@ public function implementsContainer()
{ {
$container = new SimpleContainer(); $container = new SimpleContainer();


$this->assertInstanceOf('\\YoutubeDownloader\\Container\\Container', $container); $this->assertInstanceOf(Container::class, $container);
} }


/** /**
Expand All @@ -45,8 +49,8 @@ public function isPsr11Compatible()


$adapter = new Psr11ContainerAdapter($container); $adapter = new Psr11ContainerAdapter($container);


$this->assertInstanceOf('\\Psr\\Container\\ContainerInterface', $adapter); $this->assertInstanceOf(ContainerInterface::class, $adapter);
$this->assertInstanceOf('\\YoutubeDownloader\\Container\\Container', $adapter); $this->assertInstanceOf(Container::class, $adapter);
} }


/** /**
Expand All @@ -57,7 +61,7 @@ public function testSetterAndGetterThrowsExceptionWithoutClosure($id, $value)
{ {
$container = new SimpleContainer(); $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.'); $this->expectExceptionMessage('Second argument ($value) must be a Closure or a string as alias to an existing entry.');


$container->set($id, $value); $container->set($id, $value);
Expand Down Expand Up @@ -124,7 +128,7 @@ public function getThrowsNotFoundException()
{ {
$container = new SimpleContainer(); $container = new SimpleContainer();


$this->expectException('\\YoutubeDownloader\\Container\\NotFoundException'); $this->expectException(NotFoundException::class);
$this->expectExceptionMessage('Entry "foo" don\'t exists in the container'); $this->expectExceptionMessage('Entry "foo" don\'t exists in the container');


$container->get('foo'); $container->get('foo');
Expand Down
6 changes: 4 additions & 2 deletions tests/Unit/Http/MessageTraitTest.php
Expand Up @@ -20,6 +20,8 @@


namespace YoutubeDownloader\Tests\Unit\Cache; namespace YoutubeDownloader\Tests\Unit\Cache;


use Psr\Http\Message\MessageInterface;
use YoutubeDownloader\Http\Message\Message as IMessage;
use YoutubeDownloader\Http\MessageTrait; use YoutubeDownloader\Http\MessageTrait;
use YoutubeDownloader\Tests\Fixture\Http\Message; use YoutubeDownloader\Tests\Fixture\Http\Message;
use YoutubeDownloader\Tests\Fixture\Http\Psr7MessageAdapter; use YoutubeDownloader\Tests\Fixture\Http\Psr7MessageAdapter;
Expand All @@ -36,8 +38,8 @@ public function isPsr7Compatible()


$adapter = new Psr7MessageAdapter($message); $adapter = new Psr7MessageAdapter($message);


$this->assertInstanceOf('\\Psr\\Http\\Message\\MessageInterface', $adapter); $this->assertInstanceOf(MessageInterface::class, $adapter);
$this->assertInstanceOf('\\YoutubeDownloader\\Http\\Message\\Message', $adapter); $this->assertInstanceOf(IMessage::class, $adapter);
} }


/** /**
Expand Down

0 comments on commit 467dc1e

Please sign in to comment.