Skip to content

Commit 9236f49

Browse files
authored
Update codebase to PHP 7.4 (#13)
1 parent 56a23d7 commit 9236f49

File tree

5 files changed

+30
-31
lines changed

5 files changed

+30
-31
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88

99
strategy:
1010
matrix:
11-
php: [7.1, 7.2, 7.3, 7.4, 8.0]
11+
php: [7.4, 8.0, 8.1]
1212

1313
steps:
1414
- name: Checkout code

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
],
1616
"minimum-stability": "RC",
1717
"require": {
18-
"php": "^7.1 || ^8.0",
18+
"php": "^7.4 || ^8.0",
1919
"codeception/codeception": "*@dev",
2020
"symfony/finder": ">=3.4 <6.0"
2121
},

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ A Codeception module for testing local filesystem.
99

1010
## Requirements
1111

12-
* `PHP 7.1` or higher.
12+
* `PHP 7.4` or higher.
1313

1414
## Installation
1515

src/Codeception/Module/Filesystem.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
namespace Codeception\Module;
66

7-
use Codeception\Util\FileSystem as Util;
8-
use Symfony\Component\Finder\Finder;
7+
use Codeception\Configuration;
98
use Codeception\Module;
9+
use Codeception\PHPUnit\TestCase;
1010
use Codeception\TestInterface;
11-
use Codeception\Configuration;
11+
use Codeception\Util\FileSystem as Util;
12+
use PHPUnit\Framework\AssertionFailedError;
13+
use Symfony\Component\Finder\Finder;
1214

1315
/**
1416
* Module for testing local filesystem.
@@ -24,16 +26,11 @@
2426
*/
2527
class Filesystem extends Module
2628
{
27-
protected $file;
28-
/**
29-
* @var string|null
30-
*/
31-
protected $filepath;
29+
protected string $file = '';
3230

33-
/**
34-
* @var string
35-
*/
36-
protected $path = '';
31+
protected string $filePath = '';
32+
33+
protected string $path = '';
3734

3835
public function _before(TestInterface $test): void
3936
{
@@ -56,6 +53,7 @@ protected function absolutizePath(string $path): string
5653
if (strpos($path, '/') === 0) {
5754
return $path;
5855
}
56+
5957
// windows
6058
if (strpos($path, ':\\') === 1) {
6159
return $path;
@@ -78,7 +76,7 @@ protected function absolutizePath(string $path): string
7876
public function openFile(string $filename): void
7977
{
8078
$this->file = file_get_contents($this->absolutizePath($filename));
81-
$this->filepath = $filename;
79+
$this->filePath = $filename;
8280
}
8381

8482
/**
@@ -92,8 +90,9 @@ public function openFile(string $filename): void
9290
public function deleteFile(string $filename): void
9391
{
9492
if (!file_exists($this->absolutizePath($filename))) {
95-
\Codeception\PHPUnit\TestCase::fail('file not found');
93+
TestCase::fail('file not found');
9694
}
95+
9796
unlink($this->absolutizePath($filename));
9897
}
9998

@@ -162,6 +161,7 @@ public function seeNumberNewLines(int $number): void
162161
"The number of new lines does not match with {$number}"
163162
);
164163
}
164+
165165
/**
166166
* Checks that contents of currently opened file matches $regex
167167
*/
@@ -185,7 +185,7 @@ public function seeThisFileMatches(string $regex): void
185185
public function seeFileContentsEqual(string $text): void
186186
{
187187
$file = str_replace("\r", '', $this->file);
188-
\Codeception\PHPUnit\TestCase::assertEquals($text, $file);
188+
TestCase::assertEquals($text, $file);
189189
}
190190

191191
/**
@@ -207,7 +207,7 @@ public function dontSeeInThisFile(string $text): void
207207
*/
208208
public function deleteThisFile(): void
209209
{
210-
$this->deleteFile($this->filepath);
210+
$this->deleteFile($this->filePath);
211211
}
212212

213213
/**
@@ -223,7 +223,7 @@ public function seeFileFound(string $filename, string $path = ''): void
223223
{
224224
if ($path === '' && file_exists($filename)) {
225225
$this->openFile($filename);
226-
\Codeception\PHPUnit\TestCase::assertFileExists($filename);
226+
TestCase::assertFileExists($filename);
227227
return;
228228
}
229229

@@ -234,7 +234,7 @@ public function seeFileFound(string $filename, string $path = ''): void
234234
}
235235

236236
$this->openFile($found);
237-
\Codeception\PHPUnit\TestCase::assertFileExists($found);
237+
TestCase::assertFileExists($found);
238238
}
239239

240240
/**
@@ -243,25 +243,25 @@ public function seeFileFound(string $filename, string $path = ''): void
243243
public function dontSeeFileFound(string $filename, string $path = ''): void
244244
{
245245
if ($path === '') {
246-
\Codeception\PHPUnit\TestCase::assertFileNotExists($filename);
246+
TestCase::assertFileDoesNotExist($filename);
247247
return;
248248
}
249249

250250
$found = $this->findFileInPath($filename, $path);
251251

252252
if ($found === false) {
253253
//this line keeps a count of assertions correct
254-
\Codeception\PHPUnit\TestCase::assertTrue(true);
254+
TestCase::assertTrue(true);
255255
return;
256256
}
257257

258-
\Codeception\PHPUnit\TestCase::assertFileNotExists($found);
258+
TestCase::assertFileDoesNotExist($found);
259259
}
260260

261261
/**
262262
* Finds the first matching file
263263
*
264-
* @throws \PHPUnit\Framework\AssertionFailedError When path does not exist
264+
* @throws AssertionFailedError When path does not exist
265265
* @return string|false Path to the first matching file
266266
*/
267267
private function findFileInPath(string $filename, string $path)

tests/unit/Codeception/Module/FilesystemTest.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,23 @@
22

33
declare(strict_types=1);
44

5+
use Codeception\Lib\ModuleContainer;
56
use Codeception\Module\Filesystem;
7+
use Codeception\PHPUnit\TestCase;
68
use Codeception\Stub;
79
use PHPUnit\Framework\AssertionFailedError;
810

911
if (!function_exists('make_container')) {
1012
function make_container()
1113
{
12-
return Stub::make(\Codeception\Lib\ModuleContainer::class);
14+
return Stub::make(ModuleContainer::class);
1315
}
1416
}
1517

16-
final class FilesystemTest extends \Codeception\PHPUnit\TestCase
18+
final class FilesystemTest extends TestCase
1719
{
1820

19-
/**
20-
* @var \Codeception\Module\Filesystem
21-
*/
22-
protected $module;
21+
protected ?Filesystem $module = null;
2322

2423
public function _setUp()
2524
{

0 commit comments

Comments
 (0)