Skip to content

Commit 878cba2

Browse files
authored
Merge pull request #584 from FriendsOfCake/phpunit
update dependences
2 parents a2cf020 + de16ace commit 878cba2

4 files changed

Lines changed: 25 additions & 18 deletions

File tree

composer.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
},
1818
"require-dev": {
1919
"cakephp/cakephp": "^4.0.2",
20-
"phpunit/phpunit": "~8.5.0",
20+
"phpunit/phpunit": "^8.5 || ^9.3",
2121
"cakephp/cakephp-codesniffer": "^4.0",
2222
"league/flysystem-memory": "^2.0|^3.0",
23-
"php-vfs/php-vfs": "^1.4.2"
23+
"mikey179/vfsstream": "^1.6.10"
2424
},
2525
"autoload": {
2626
"psr-4": {
@@ -32,5 +32,10 @@
3232
"psr-4": {
3333
"Josegonzalez\\Upload\\Test\\": "tests"
3434
}
35+
},
36+
"config": {
37+
"allow-plugins": {
38+
"dealerdirect/phpcodesniffer-composer-installer": true
39+
}
3540
}
3641
}

phpunit.xml.dist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
processIsolation="false"
44
stopOnFailure="false"
55
bootstrap="./tests/bootstrap.php"
6+
convertDeprecationsToExceptions="true"
67
>
78
<php>
89
<ini name="memory_limit" value="-1"/>
10+
<!-- E_ALL & ~E_USER_DEPRECATED (16383)-->
11+
<!-- E_ALL (32767) -->
12+
<ini name="error_reporting" value="32767"/>
913
<ini name="apc.enable_cli" value="1"/>
1014
</php>
1115

tests/TestCase/File/Writer/DefaultWriterTest.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use League\Flysystem\UnableToDeleteFile;
1111
use League\Flysystem\UnableToMoveFile;
1212
use League\Flysystem\UnableToWriteFile;
13-
use VirtualFileSystem\FileSystem as Vfs;
13+
use org\bovigo\vfs\vfsStream as Vfs;
1414

1515
class DefaultWriterTest extends TestCase
1616
{
@@ -43,9 +43,8 @@ public function setUp(): void
4343
$this->settings
4444
);
4545

46-
$this->vfs = new Vfs();
47-
mkdir($this->vfs->path('/tmp'));
48-
file_put_contents($this->vfs->path('/tmp/tempfile'), 'content');
46+
$this->vfs = Vfs::setup('tmp');
47+
file_put_contents($this->vfs->url() . '/tempfile', 'content');
4948
}
5049

5150
public function testIsWriterInterface()
@@ -57,11 +56,11 @@ public function testInvoke()
5756
{
5857
$this->assertEquals([], $this->writer->write([]));
5958
$this->assertEquals([true], $this->writer->write([
60-
$this->vfs->path('/tmp/tempfile') => 'file.txt',
59+
$this->vfs->url() . '/tempfile' => 'file.txt',
6160
], 'field', []));
6261

6362
$this->assertEquals([false], $this->writer->write([
64-
$this->vfs->path('/tmp/invalid.txt') => 'file.txt',
63+
$this->vfs->url() . '/invalid.txt' => 'file.txt',
6564
], 'field', []));
6665
}
6766

@@ -78,11 +77,11 @@ public function testDelete()
7877

7978
$this->assertEquals([], $writer->delete([]));
8079
$this->assertEquals([true], $writer->delete([
81-
$this->vfs->path('/tmp/tempfile'),
80+
$this->vfs->url() . '/tempfile',
8281
]));
8382

8483
$this->assertEquals([false], $writer->delete([
85-
$this->vfs->path('/tmp/invalid.txt'),
84+
$this->vfs->url() . '/invalid.txt',
8685
]));
8786
}
8887

@@ -92,19 +91,19 @@ public function testWriteFile()
9291
$filesystem->expects($this->once())->method('writeStream');
9392
$filesystem->expects($this->exactly(3))->method('delete');
9493
$filesystem->expects($this->once())->method('move');
95-
$this->assertTrue($this->writer->writeFile($filesystem, $this->vfs->path('/tmp/tempfile'), 'path'));
94+
$this->assertTrue($this->writer->writeFile($filesystem, $this->vfs->url() . '/tempfile', 'path'));
9695

9796
$filesystem = $this->getMockBuilder('League\Flysystem\FilesystemOperator')->getMock();
9897
$filesystem->expects($this->once())->method('writeStream')->will($this->throwException(new UnableToWriteFile()));
9998
$filesystem->expects($this->exactly(2))->method('delete');
10099
$filesystem->expects($this->never())->method('move');
101-
$this->assertFalse($this->writer->writeFile($filesystem, $this->vfs->path('/tmp/tempfile'), 'path'));
100+
$this->assertFalse($this->writer->writeFile($filesystem, $this->vfs->url() . '/tempfile', 'path'));
102101

103102
$filesystem = $this->getMockBuilder('League\Flysystem\FilesystemOperator')->getMock();
104103
$filesystem->expects($this->once())->method('writeStream');
105104
$filesystem->expects($this->exactly(3))->method('delete');
106105
$filesystem->expects($this->once())->method('move')->will($this->throwException(new UnableToMoveFile()));
107-
$this->assertFalse($this->writer->writeFile($filesystem, $this->vfs->path('/tmp/tempfile'), 'path'));
106+
$this->assertFalse($this->writer->writeFile($filesystem, $this->vfs->url() . '/tempfile', 'path'));
108107
}
109108

110109
public function testDeletePath()

tests/TestCase/Validation/ImageValidationTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Cake\TestSuite\TestCase;
77
use Josegonzalez\Upload\Validation\ImageValidation;
88
use Laminas\Diactoros\UploadedFile;
9-
use VirtualFileSystem\FileSystem as Vfs;
9+
use org\bovigo\vfs\vfsStream as Vfs;
1010

1111
class ImageValidationTest extends TestCase
1212
{
@@ -17,18 +17,17 @@ public function setUp(): void
1717
{
1818
parent::setUp();
1919

20-
$this->vfs = new Vfs();
21-
mkdir($this->vfs->path('/tmp'));
20+
$this->vfs = Vfs::setup('tmp');
2221

2322
// Write sample image with dimensions: 20x20
24-
$img = fopen($this->vfs->path('/tmp/tmpimage'), 'wb');
23+
$img = fopen($this->vfs->url() . '/tmpimage', 'wb');
2524
fwrite($img, base64_decode('iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAB3RJTUUH4AMUECwX5I9GIwAAACFJREFUOMtj/P//PwM1ARMDlcGogaMGjho4auCogUPFQABpCwMlgqgSYAAAAABJRU5ErkJggg=='));
2625
fclose($img);
2726

2827
$this->data = [
2928
'name' => 'sample.txt',
3029
'type' => 'text/plain',
31-
'tmp_name' => $this->vfs->path('/tmp/tmpimage'),
30+
'tmp_name' => $this->vfs->url() . '/tmpimage',
3231
'size' => 200,
3332
'error' => UPLOAD_ERR_OK,
3433
];

0 commit comments

Comments
 (0)