From c02a4e333f10866fe5c785206720ebff2c4dde67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Fri, 21 Apr 2017 08:43:44 +0200 Subject: [PATCH 1/2] Enhancement: Raise minimum PHP version to PHP 7.1 --- .travis.yml | 18 ------------------ composer.json | 2 +- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4081dd6..5dc848a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,24 +23,6 @@ env: matrix: include: - - php: 5.5 - env: - - CS_CHECK=true - - php: 5.5 - env: - - ZEND_SERVICEMANAGER_VERSION="^2.7.5" - - php: 5.6 - env: - - TEST_COVERAGE=true - - DEPLOY_DOCS="$(if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then echo -n 'true' ; else echo -n 'false' ; fi)" - - PATH="$HOME/.local/bin:$PATH" - - php: 5.6 - env: - - ZEND_SERVICEMANAGER_VERSION="^2.7.5" - - php: 7.0 - - php: 7.0 - env: - - ZEND_SERVICEMANAGER_VERSION="^2.7.5" - php: 7.1 - php: 7.1 env: diff --git a/composer.json b/composer.json index 3fb0b6a..87d0fff 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } }, "require": { - "php": "^5.5 || ^7.0", + "php": "^7.1", "zendframework/zend-stdlib": "^2.7 || ^3.0" }, "require-dev": { From 7c1e85a58752b4a191bff7b9db8106a2d369b79b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Fri, 21 Apr 2017 08:59:45 +0200 Subject: [PATCH 2/2] Enhancement: Update phpunit/phpunit --- composer.json | 2 +- test/ClassFileLocatorTest.php | 10 ++++-- test/Transfer/Adapter/AbstractTest.php | 44 +++++++++++++++----------- test/Transfer/Adapter/HttpTest.php | 9 ++++-- 4 files changed, 40 insertions(+), 25 deletions(-) diff --git a/composer.json b/composer.json index 87d0fff..7ccfff4 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ }, "require-dev": { "fabpot/php-cs-fixer": "1.7.*", - "phpunit/phpunit": "~4.0", + "phpunit/phpunit": "^6.1.4", "zendframework/zend-coding-standard": "~1.0.0", "zendframework/zend-filter": "^2.6.1", "zendframework/zend-i18n": "^2.6", diff --git a/test/ClassFileLocatorTest.php b/test/ClassFileLocatorTest.php index ee6c9e8..20d6018 100644 --- a/test/ClassFileLocatorTest.php +++ b/test/ClassFileLocatorTest.php @@ -9,6 +9,7 @@ namespace ZendTest\File; +use PHPUnit\Framework; use Zend\File\ClassFileLocator; use Zend\File\Exception; use Zend\File\PhpClassFile; @@ -18,18 +19,21 @@ * * @group Zend_File */ -class ClassFileLocatorTest extends \PHPUnit_Framework_TestCase +class ClassFileLocatorTest extends Framework\TestCase { public function testConstructorThrowsInvalidArgumentExceptionForInvalidStringDirectory() { - $this->setExpectedException(Exception\InvalidArgumentException::class); + $this->expectException(Exception\InvalidArgumentException::class); + $locator = new ClassFileLocator('__foo__'); } public function testConstructorThrowsInvalidArgumentExceptionForNonDirectoryIteratorArgument() { $iterator = new \ArrayIterator([]); - $this->setExpectedException(Exception\InvalidArgumentException::class); + + $this->expectException(Exception\InvalidArgumentException::class); + $locator = new ClassFileLocator($iterator); } diff --git a/test/Transfer/Adapter/AbstractTest.php b/test/Transfer/Adapter/AbstractTest.php index 6ab9f49..6468c5c 100644 --- a/test/Transfer/Adapter/AbstractTest.php +++ b/test/Transfer/Adapter/AbstractTest.php @@ -10,6 +10,7 @@ namespace ZendTest\File\Transfer\Adapter; use Interop\Container\ContainerInterface; +use PHPUnit\Framework; use stdClass; use Zend\File; use Zend\Filter; @@ -21,7 +22,7 @@ * * @group Zend_File */ -class AbstractTest extends \PHPUnit_Framework_TestCase +class AbstractTest extends Framework\TestCase { /** * Sets up the fixture, for example, open a network connection. @@ -75,10 +76,9 @@ public function testAdapterShouldAllowAddingValidatorViaPluginManager() public function testAdapterhShouldRaiseExceptionWhenAddingInvalidValidatorType() { - $this->setExpectedException( - File\Transfer\Exception\InvalidArgumentException::class, - 'Invalid validator provided to addValidator' - ); + $this->expectException(File\Transfer\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('Invalid validator provided to addValidator'); + $this->adapter->addValidator(new Filter\BaseName); } @@ -272,10 +272,9 @@ public function testAdapterShouldAllowAddingFilterViaPluginManager() public function testAdapterhShouldRaiseExceptionWhenAddingInvalidFilterType() { - $this->setExpectedException( - File\Transfer\Exception\InvalidArgumentException::class, - 'Invalid filter specified' - ); + $this->expectException(File\Transfer\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('Invalid filter specified'); + $this->adapter->addFilter(new stdClass()); } @@ -463,10 +462,9 @@ public function testGetAdditionalFileInfosForSingleFile() public function testGetAdditionalFileInfosForUnknownFile() { - $this->setExpectedException( - File\Transfer\Exception\RuntimeException::class, - 'The file transfer adapter can not find "unknown"' - ); + $this->expectException(File\Transfer\Exception\RuntimeException::class); + $this->expectExceptionMessage('The file transfer adapter can not find "unknown"'); + $files = $this->adapter->getFileInfo('unknown'); } @@ -508,7 +506,9 @@ public function testAdapterShouldAllowRetrievingAllFileNamesWithoutPath() public function testExceptionForUnknownHashValue() { - $this->setExpectedException(File\Transfer\Exception\InvalidArgumentException::class, 'Unknown hash algorithm'); + $this->expectException(File\Transfer\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('Unknown hash algorithm'); + $this->adapter->getHash('foo', 'unknown_hash'); } @@ -541,7 +541,9 @@ public function testTemporaryDirectoryAccessDetection() public function testFileSizeButNoFileFound() { - $this->setExpectedException(File\Transfer\Exception\InvalidArgumentException::class, 'does not exist'); + $this->expectException(File\Transfer\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('does not exist'); + $this->assertEquals(10, $this->adapter->getFileSize()); } @@ -566,7 +568,9 @@ public function testFileSizeByTmpName() public function testMimeTypeButNoFileFound() { - $this->setExpectedException(File\Transfer\Exception\InvalidArgumentException::class, 'does not exist'); + $this->expectException(File\Transfer\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('does not exist'); + $this->assertEquals('image/jpeg', $this->adapter->getMimeType()); } @@ -593,7 +597,9 @@ public function testSetOwnErrorMessage() $message = $this->adapter->getMessages(); $this->assertContains('Zu wenige', $message); - $this->setExpectedException(File\Transfer\Exception\InvalidArgumentException::class, 'does not exist'); + $this->expectException(File\Transfer\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('does not exist'); + $this->assertEquals('image/jpeg', $this->adapter->getMimeType()); } @@ -603,7 +609,9 @@ public function testTransferDestinationAtNonExistingElement() $this->adapter->setDestination($directory, 'nonexisting'); $this->assertEquals($directory, $this->adapter->getDestination('nonexisting')); - $this->setExpectedException(File\Transfer\Exception\InvalidArgumentException::class, 'not find'); + $this->expectException(File\Transfer\Exception\InvalidArgumentException::class); + $this->expectExceptionMessage('not find'); + $this->assertInternalType('string', $this->adapter->getDestination('reallynonexisting')); } diff --git a/test/Transfer/Adapter/HttpTest.php b/test/Transfer/Adapter/HttpTest.php index c7b35ae..90a60e8 100644 --- a/test/Transfer/Adapter/HttpTest.php +++ b/test/Transfer/Adapter/HttpTest.php @@ -9,6 +9,7 @@ namespace ZendTest\File\Transfer\Adapter; +use PHPUnit\Framework; use Zend\File\Transfer\Adapter; use Zend\File\Transfer\Exception\BadMethodCallException; use Zend\File\Transfer\Exception\RuntimeException; @@ -20,7 +21,7 @@ * * @group Zend_File */ -class HttpTest extends \PHPUnit_Framework_TestCase +class HttpTest extends Framework\TestCase { /** * Sets up the fixture, for example, open a network connection. @@ -71,13 +72,15 @@ public function testAutoSetUploadValidator() public function testSendingFiles() { - $this->setExpectedException(BadMethodCallException::class, 'not implemented'); + $this->expectException(BadMethodCallException::class, 'not implemented'); + $this->adapter->send(); } public function testFileIsSent() { - $this->setExpectedException(BadMethodCallException::class, 'not implemented'); + $this->expectException(BadMethodCallException::class, 'not implemented'); + $this->adapter->isSent(); }