Skip to content

Commit

Permalink
Drop support for PHP 5.6 and PHP 7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurHoaro committed Aug 10, 2019
1 parent 03bbeaf commit 609a495
Show file tree
Hide file tree
Showing 17 changed files with 101 additions and 84 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ cache:
directories:
- $HOME/.composer/cache
php:
- 7.3
- 7.2
- 7.1
- 7.0
- 5.6
install:
- composer self-update
- composer install --prefer-dist
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ PHP library which will retrieve a thumbnail for any given URL, if available.

Mandatory:

- PHP 5.6
- PHP 7.1 (`v2.0.0`+) - PHP 5.6 (`v1.x.x`)
- PHP GD extension

(Highly) Recommended:
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
}
],
"require": {
"php": ">=5.6",
"php": ">=7.1",
"phpunit/php-text-template": "^1.2"
},
"require-dev": {
"phpunit/phpunit": "^5.0 || ^6.0 || ^7.0 || ^8.0",
"phpunit/phpunit": "^7.0 || ^8.0",
"php-coveralls/php-coveralls": "^2.0",
"squizlabs/php_codesniffer": "^3.0"
},
Expand Down
26 changes: 12 additions & 14 deletions tests/WebThumbnailer/Application/CacheManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace WebThumbnailer\Application;

use PHPUnit\Framework\TestCase;
use WebThumbnailer\Utils\FileUtils;

/**
Expand All @@ -11,7 +12,7 @@
*
* @package WebThumbnailer\Application
*/
class CacheManagerTest extends \PHPUnit_Framework_TestCase
class CacheManagerTest extends TestCase
{
/**
* @var string $cache relative path.
Expand All @@ -21,7 +22,7 @@ class CacheManagerTest extends \PHPUnit_Framework_TestCase
/**
* Load test config before running tests.
*/
public function setUp()
public function setUp(): void
{
$resource = 'tests/WebThumbnailer/resources/';
ConfigManager::$configFiles = [$resource . 'settings-useful.json'];
Expand All @@ -31,7 +32,7 @@ public function setUp()
/**
* Remove cache folder after every tests.
*/
public function tearDown()
public function tearDown(): void
{
FileUtils::rmdir(ConfigManager::get('settings.path.cache'));
}
Expand All @@ -43,32 +44,29 @@ public function testGetCachePathValid()
{
$path = CacheManager::getCachePath(CacheManager::TYPE_THUMB);
$this->assertTrue(is_dir($path));
$this->assertContains(self::$cache . CacheManager::TYPE_THUMB .'/', $path);
$this->assertStringContainsString(self::$cache . CacheManager::TYPE_THUMB .'/', $path);
$path = CacheManager::getCachePath(CacheManager::TYPE_FINDER);
$this->assertTrue(is_dir($path));
$this->assertContains(self::$cache . CacheManager::TYPE_FINDER .'/', $path);
$this->assertStringContainsString(self::$cache . CacheManager::TYPE_FINDER .'/', $path);
}

/**
* Test getCachePath() with an invalid type.
*
* @expectedException \Exception
* @expectedExceptionMessageRegExp /Unknown cache type/
*/
public function testGetCachePathInvalidType()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessageRegExp('/Unknown cache type/');
CacheManager::getCachePath('nope');
}

/**
* Test getCachePath() without cache folder.
*
* @expectedException \Exception
* @expectedExceptionMessageRegExp /Cache folders are not writable/
*
*/
public function testGetCachePathNoFolder()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessageRegExp('/Cache folders are not writable/');
CacheManager::getCachePath(CacheManager::TYPE_THUMB, true);
}

Expand All @@ -85,9 +83,9 @@ public function testGetCacheFilePathValid()
$cacheFile = CacheManager::getCacheFilePath($url, $domain, $type, $width, $height, false);
$whateverDir = self::$cache . 'thumb/'. md5($domain) .'/';
$this->assertTrue(is_dir($whateverDir));
$this->assertContains($whateverDir, $cacheFile);
$this->assertStringContainsString($whateverDir, $cacheFile);
// sha1 sum + dimensions
$this->assertContains('0a35602901944a0c6d853da2a5364665c2bda069' . '51200' . '.jpg', $cacheFile);
$this->assertStringContainsString('0a35602901944a0c6d853da2a5364665c2bda069' . '51200' . '.jpg', $cacheFile);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions tests/WebThumbnailer/Application/ConfigManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace WebThumbnailer\Application;

use PHPUnit\Framework\TestCase;
use WebThumbnailer\Utils\DataUtils;
use WebThumbnailer\Utils\FileUtils;

Expand All @@ -12,12 +13,12 @@
*
* @package WebThumbnailer\Application
*/
class ConfigManagerTest extends \PHPUnit_Framework_TestCase
class ConfigManagerTest extends TestCase
{
/**
* Before each test method.
*/
public function setUp()
public function setUp(): void
{
ConfigManager::$configFiles = [];
ConfigManager::reload();
Expand Down
11 changes: 6 additions & 5 deletions tests/WebThumbnailer/Application/ThumbnailerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace WebThumbnailer\Application;

use PHPUnit\Framework\TestCase;
use WebThumbnailer\Exception\BadRulesException;
use WebThumbnailer\Utils\FileUtils;
use WebThumbnailer\Utils\SizeUtils;
use WebThumbnailer\WebThumbnailer;
Expand All @@ -13,7 +15,7 @@
*
* @package WebThumbnailer\Application
*/
class ThumbnailerTest extends \PHPUnit_Framework_TestCase
class ThumbnailerTest extends TestCase
{
/**
* @var string Gravatar image link.
Expand All @@ -25,7 +27,7 @@ class ThumbnailerTest extends \PHPUnit_Framework_TestCase
*/
public static $gravatarThumb = 'http://gravatar.com/avatar/69ae657aa40c6c777aa2f391a63f327f?s=320';

public function setUp()
public function setUp(): void
{
FileUtils::rmdir(__DIR__ .'/../../../cache/finder');
FileUtils::rmdir(__DIR__ .'/../../../cache/thumb');
Expand Down Expand Up @@ -184,12 +186,11 @@ public function testDownloadSizedThumbnailWidth()

/**
* Try to create an instance of Thumbnailer with incompatible settings.
*
* @expectedException WebThumbnailer\Exception\BadRulesException
* @expectedExceptionMessageRegExp /Only one of these flags can be set between: DOWNLOAD HOTLINK HOTLINK_STRICT/
*/
public function testDownloadBadConfigurationDownload()
{
$this->expectException(BadRulesException::class);
$this->expectExceptionMessageRegExp('/Only one of these flags can be set between: DOWNLOAD HOTLINK HOTLINK_STRICT/');
$options = [
WebThumbnailer::DOWNLOAD,
WebThumbnailer::HOTLINK_STRICT,
Expand Down
3 changes: 2 additions & 1 deletion tests/WebThumbnailer/Finder/DefaultFinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

namespace WebThumbnailer\Finder;

use PHPUnit\Framework\TestCase;
use WebThumbnailer\WebThumbnailer;

/**
* Class DefaultFinderTest
*
* @package WebThumbnailer\Finder
*/
class DefaultFinderTest extends \PHPUnit_Framework_TestCase
class DefaultFinderTest extends TestCase
{
/**
* PHP builtin local server URL.
Expand Down
9 changes: 6 additions & 3 deletions tests/WebThumbnailer/Finder/FinderFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

namespace WebThumbnailer\Finder;

use PHPUnit\Framework\TestCase;
use WebThumbnailer\Exception\BadRulesException;

/**
* Class FinderFactoryTest
*
* @package WebThumbnailer\Finder
*/
class FinderFactoryTest extends \PHPUnit_Framework_TestCase
class FinderFactoryTest extends TestCase
{
/**
* Test getFinder() with a supported domain.
Expand Down Expand Up @@ -178,6 +181,7 @@ public function testGetThumbnailMetaGravatar()
*/
public function testCheckMetaFormatValid()
{
$this->addToAssertionCount(1);
$meta = [
'finder' => 'foo',
'domains' => ['bar']
Expand All @@ -189,11 +193,10 @@ public function testCheckMetaFormatValid()

/**
* Test checkMetaFormat() with invalid info.
*
* @expectedException \WebThumbnailer\Exception\BadRulesException
*/
public function testCheckMetaFormatBadRules()
{
$this->expectException(BadRulesException::class);
$meta = array('finder' => 'test');
FinderFactory::checkMetaFormat($meta);
}
Expand Down
6 changes: 4 additions & 2 deletions tests/WebThumbnailer/Finder/FlickRFinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

namespace WebThumbnailer\Finder;

use PHPUnit\Framework\TestCase;

/**
* Class FlickRFinderTest
*
* @package WebThumbnailer\Finder
*/
class FlickRFinderTest extends \PHPUnit_Framework_TestCase
class FlickRFinderTest extends TestCase
{
/**
* @var array Finder rules.
Expand All @@ -22,7 +24,7 @@ class FlickRFinderTest extends \PHPUnit_Framework_TestCase
/**
* Before every tests, reset rules and params.
*/
public function setUp()
public function setUp(): void
{
self::$rules = [
'image_regex' => '<meta property=\"og:image\" content=\"(.*?)\"',
Expand Down
18 changes: 9 additions & 9 deletions tests/WebThumbnailer/Finder/QueryRegexFinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace WebThumbnailer\Finder;

use PHPUnit\Framework\TestCase;
use WebThumbnailer\Exception\BadRulesException;
use WebThumbnailer\Utils\DataUtils;
use WebThumbnailer\Utils\FileUtils;

Expand All @@ -10,7 +12,7 @@
*
* @package WebThumbnailer\Finder
*/
class QueryRegexFinderTest extends \PHPUnit_Framework_TestCase
class QueryRegexFinderTest extends TestCase
{
/**
* @var array Finder rules.
Expand All @@ -25,7 +27,7 @@ class QueryRegexFinderTest extends \PHPUnit_Framework_TestCase
/**
* Before every tests, reset rules and params.
*/
public function setUp()
public function setUp(): void
{
self::$rules = [
'image_regex' => '<img class="thumb" src="(.*?)" alt="(.*?)">',
Expand Down Expand Up @@ -164,22 +166,20 @@ public function testGetName()

/**
* Test loading the finder with bad rules (`thumbnail_url`).
*
* @expectedException \WebThumbnailer\Exception\BadRulesException
*/
public function testQueryRegexFinderBadRulesThumbUrl()
{
$this->expectException(BadRulesException::class);
unset(self::$rules['thumbnail_url']);
new QueryRegexFinder('domain.tld', '', self::$rules, null);
}

/**
* Test loading the finder with bad rules (`image_regex`).
*
* @expectedException \WebThumbnailer\Exception\BadRulesException
*/
public function testQueryRegexFinderBadRulesImageRegex()
{
$this->expectException(BadRulesException::class);
unset(self::$rules['image_regex']);
new QueryRegexFinder('domain.tld', '', self::$rules, null);
}
Expand Down Expand Up @@ -217,12 +217,12 @@ public function testQueryRegexNoEnoughMatch()

/**
* Use an unknown option in the URL.
*
* @expectedException \Exception
* @expectedExceptionMessage Unknown option "option" for the finder "Query Regex"
*/
public function testQueryRegexUnknownOption()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Unknown option "option" for the finder "Query Regex"');

$url = __DIR__ . '/../resources/queryregex/one-thumb.html';
self::$rules['thumbnail_url'] = '${option}';
$finder = new QueryRegexFinder('domain.tld', $url, self::$rules, null);
Expand Down
Loading

0 comments on commit 609a495

Please sign in to comment.