Skip to content

Commit e8302a4

Browse files
author
Alcides Ramos
committed
tests: allow to mock final classes
1 parent 1e293be commit e8302a4

5 files changed

Lines changed: 248 additions & 101 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
vendor/*
1+
vendor/*
2+
.coverage

app/Providers/Foo.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,21 @@
44

55
namespace App\Providers;
66

7+
use DateTimeImmutable;
8+
79
final class Foo
810
{
911
public static function dump(): string
1012
{
11-
$date = date('d-M-Y H:i:s');
13+
$date = (new DateTimeImmutable())->format('Y-m-d H:i:s');
14+
1215
$line = 'Executed method [ ' . __FUNCTION__ . ' ] in [ ' . getenv('ENV') . ' ] mode' . PHP_EOL;
1316

1417
return sprintf('[%s] %s: %s', $date, self::class, $line);
1518
}
19+
20+
public function ping(): string
21+
{
22+
return 'pong';
23+
}
1624
}

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"autoload-dev": {
2727
"psr-4": {
28-
"Tests\\Unit\\": "tests/Unit"
28+
"UnitTests\\": "tests/Unit"
2929
}
3030
},
3131
"config": {
@@ -38,6 +38,7 @@
3838
}
3939
},
4040
"require-dev": {
41+
"nunomaduro/mock-final-classes": "^1.2",
4142
"php-parallel-lint/php-console-highlighter": "^1.0",
4243
"php-parallel-lint/php-parallel-lint": "^1.3",
4344
"phpmd/phpmd": "^2.15",

0 commit comments

Comments
 (0)