Skip to content

Commit 9bf7ce9

Browse files
committed
Upgrade PHPUnit to v9.4, adjust tests
1 parent c64d41c commit 9bf7ce9

16 files changed

Lines changed: 69 additions & 51 deletions

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"require-dev": {
2323
"mockery/mockery": "^1.0",
24-
"phpunit/phpunit": "^5.7",
24+
"phpunit/phpunit": "^9.4",
2525
"mikey179/vfsstream": "^1.6"
2626
}
2727
}

phpunit.xml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,24 @@
11
<phpunit backupGlobals="false"
22
backupStaticAttributes="false"
33
bootstrap="vendor/autoload.php"
4-
cacheTokens="true"
54
colors="true"
65
convertErrorsToExceptions="true"
76
convertNoticesToExceptions="true"
87
convertWarningsToExceptions="true"
98
forceCoversAnnotation="false"
10-
mapTestClassNameToCoveredClassName="false"
11-
printerClass="PHPUnit_TextUI_ResultPrinter"
129
processIsolation="false"
1310
stopOnError="true"
1411
stopOnFailure="true"
1512
stopOnIncomplete="false"
1613
stopOnSkipped="false"
17-
testSuiteLoaderClass="PHPUnit_Runner_StandardTestSuiteLoader"
18-
strict="false"
1914
verbose="false">
2015

2116
<php>
2217
<env name="APPLICATION_ENV" value="testing"/>
2318
</php>
2419

2520
<testsuites>
26-
<testsuite>
21+
<testsuite name="Tests">
2722
<directory>test</directory>
2823
</testsuite>
2924
</testsuites>

test/integration/ApplicationTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
namespace Barberry;
44

5+
use PHPUnit\Framework\TestCase;
56
use Symfony\Component\HttpFoundation;
67

7-
class ApplicationTest extends \PHPUnit_Framework_TestCase
8+
class ApplicationTest extends TestCase
89
{
910
public function testCanRun(): void
1011
{

test/integration/CacheTest.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
<?php
2+
23
namespace Barberry;
34

4-
use Barberry\nonlinear;
55
use Barberry\Test;
6+
use PHPUnit\Framework\TestCase;
67

7-
class CacheIntegrationTest extends \PHPUnit_Framework_TestCase {
8+
class CacheIntegrationTest extends TestCase
9+
{
810

911
private $cache_path;
1012

11-
protected function setUp() {
13+
protected function setUp(): void
14+
{
1215
$this->cache_path = '/tmp/testCache/';
1316
@mkdir($this->cache_path);
1417
}
1518

16-
protected function tearDown() {
19+
protected function tearDown(): void
20+
{
1721
exec('rm -rf ' . $this->cache_path);
1822
}
1923

20-
public function testIsContentSavedInFileSystem() {
24+
public function testIsContentSavedInFileSystem()
25+
{
2126
$this->cache()->save(
2227
Test\Data::gif1x1(),
2328
new Request('/7yU98sd_1x1.gif')
@@ -28,7 +33,8 @@ public function testIsContentSavedInFileSystem() {
2833
$this->assertEquals(file_get_contents($expectedPath), Test\Data::gif1x1());
2934
}
3035

31-
public function testIsContentSavedInFileSystemInGroupDirectory() {
36+
public function testIsContentSavedInFileSystemInGroupDirectory()
37+
{
3238
$this->cache()->save(
3339
Test\Data::gif1x1(),
3440
new Request('/adm/7yU98sd_1x1.gif')
@@ -51,7 +57,8 @@ public function testInvalidateRemovesCachedContent()
5157
$this->assertFalse(is_dir($this->cache_path . '/7y/U9/8s/7yU98sd'));
5258
}
5359

54-
private function cache() {
60+
private function cache()
61+
{
5562
return new Cache($this->cache_path);
5663
}
5764
}

test/integration/Storage/FileTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,21 @@
66
use Barberry\fs;
77
use GuzzleHttp\Psr7\UploadedFile;
88
use GuzzleHttp\Psr7\Utils;
9+
use PHPUnit\Framework\TestCase;
910

10-
class FileTest extends \PHPUnit_Framework_TestCase
11+
class FileTest extends TestCase
1112
{
1213
private $storage_path;
1314

14-
protected function setUp()
15+
protected function setUp(): void
1516
{
1617
$this->storage_path = '/tmp/testStorage/';
1718
if (!is_dir($this->storage_path)) {
1819
mkdir($this->storage_path);
1920
}
2021
}
2122

22-
protected function tearDown()
23+
protected function tearDown(): void
2324
{
2425
fs\rmDirRecursive($this->storage_path);
2526
}
@@ -77,13 +78,13 @@ public function testIsFileDeletedById()
7778

7879
public function testNotFoundException()
7980
{
80-
$this->setExpectedException('Barberry\\Storage\\NotFoundException');
81+
$this->expectException(NotFoundException::class);
8182
$this->storage()->getById('not-existing-id');
8283
}
8384

8485
public function testGetByIdTestsForFileExistance()
8586
{
86-
$this->setExpectedException('Barberry\\Storage\\NotFoundException');
87+
$this->expectException(NotFoundException::class);
8788
$this->storage()->getById('/');
8889
}
8990

test/unit/CacheTest.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
use GuzzleHttp\Psr7\Utils;
66
use Mockery as m;
77
use org\bovigo\vfs\vfsStream;
8+
use PHPUnit\Framework\TestCase;
89

9-
class CacheTest extends \PHPUnit_Framework_TestCase
10+
class CacheTest extends TestCase
1011
{
1112
use m\Adapter\Phpunit\MockeryPHPUnitIntegration;
1213

@@ -28,18 +29,10 @@ public function setUp(): void
2829
*/
2930
public function testConvertsUriToFilePath(string $uri, string $expectedPath): void
3031
{
31-
$cache = $this->getMockBuilder(Cache::class)
32-
->setMethods(['writeToFilesystem'])
33-
->enableOriginalConstructor()
34-
->setConstructorArgs([self::$filesystem->url() . '/cache'])
35-
->getMock();
36-
37-
$cache
38-
->expects($this->any())
39-
->method('writeToFilesystem')
40-
->with('123', $expectedPath);
41-
32+
$cache = new Cache(self::$filesystem->url() . '/cache');
4233
$cache->save('123', new Request($uri));
34+
35+
self::assertFileExists(self::$filesystem->url() . '/cache' . $expectedPath);
4336
}
4437

4538
public function testStreamDataCanBeSaved(): void

test/unit/ConfigTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
<?php
2+
23
namespace Barberry;
34

4-
class ConfigTest extends \PHPUnit_Framework_TestCase {
5+
use PHPUnit\Framework\TestCase;
56

6-
public function testOptionsCanBeOverriden() {
7+
class ConfigTest extends TestCase
8+
{
9+
public function testOptionsCanBeOverriden()
10+
{
711
$config = new Config(__DIR__, '/test_config.php');
812
$this->assertEquals('/usr/another/storage', $config->directoryStorage);
913
}

test/unit/ControllerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
use GuzzleHttp\Psr7\Utils;
1414
use Mockery as m;
1515
use org\bovigo\vfs\vfsStream;
16+
use PHPUnit\Framework\TestCase;
1617
use Symfony\Component\HttpFoundation;
1718

18-
class ControllerTest extends \PHPUnit_Framework_TestCase
19+
class ControllerTest extends TestCase
1920
{
2021
use m\Adapter\Phpunit\MockeryPHPUnitIntegration;
2122

test/unit/Direction/FactoryTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
<?php
2+
23
namespace Barberry\Direction;
4+
35
use Barberry\ContentType;
4-
use Barberry\Plugin;
6+
use Barberry\Plugin\NotAvailableException;
7+
use PHPUnit\Framework\TestCase;
58

6-
class FactoryTest extends \PHPUnit_Framework_TestCase {
9+
class FactoryTest extends TestCase
10+
{
711

812
public function testDetectsDirectionClassName() {
913
$this->assertInstanceOf(
@@ -13,7 +17,7 @@ public function testDetectsDirectionClassName() {
1317
}
1418

1519
public function testThrowExceptionWhenDirectionIsNotAvailable() {
16-
$this->setExpectedException('Barberry\Plugin\NotAvailableException', 'text/x-php to image/jpeg');
20+
$this->expectException(NotAvailableException::class);
1721
self::factory()->direction(ContentType::byExtention('php'), ContentType::byExtention('jpeg'));
1822
}
1923

@@ -25,7 +29,7 @@ public function testSameSourceAndDestinationWithoutCommandActivatesNullPlugin()
2529
}
2630

2731
public function testSameSourceAndDestinationWithCommandRequiresPlugin() {
28-
$this->setExpectedException('Barberry\Plugin\NotAvailableException');
32+
$this->expectException(NotAvailableException::class);
2933
self::factory()->direction(ContentType::byExtention('php'), ContentType::byExtention('php'), '12');
3034
}
3135

test/unit/Filter/FilterCompositeTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
use Barberry\PostedFile\Collection;
66
use GuzzleHttp\Psr7\UploadedFile;
77
use GuzzleHttp\Psr7\Utils;
8+
use PHPUnit\Framework\TestCase;
89

9-
class FilterCompositeTest extends \PHPUnit_Framework_TestCase
10+
class FilterCompositeTest extends TestCase
1011
{
1112

1213
public function testImplementsFilterInterface()

0 commit comments

Comments
 (0)