Skip to content

Commit 6e806d0

Browse files
committed
#85995 fix review
1 parent bcfd52d commit 6e806d0

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

tests/GenerateServerTest.php

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,13 @@
55
use Illuminate\Filesystem\Filesystem;
66
use Illuminate\Support\Facades\Config;
77
use function Pest\Laravel\artisan;
8-
use function PHPUnit\Framework\assertEquals;
8+
use function PHPUnit\Framework\assertEqualsCanonicalizing;
99

10-
function makeFilePath(string $path): string
11-
{
12-
return str_replace('/', DIRECTORY_SEPARATOR, $path);
13-
}
1410
test("Command GenerateServer success", function () {
1511
/** @var TestCase $this */
1612
$mapping = Config::get('openapi-server-generator.api_docs_mappings');
1713
$mappingValue = current($mapping);
18-
$mapping = [makeFilePath(__DIR__ . '/resources/index.yaml') => $mappingValue];
14+
$mapping = [$this->makeFilePath(__DIR__ . '/resources/index.yaml') => $mappingValue];
1915
Config::set('openapi-server-generator.api_docs_mappings', $mapping);
2016

2117
$filesystem = $this->mock(Filesystem::class);
@@ -26,34 +22,31 @@ function makeFilePath(string $path): string
2622
return file_get_contents($path);
2723
});
2824
$filesystem->shouldReceive('cleanDirectory', 'ensureDirectoryExists');
29-
$appRoot = realpath(makeFilePath(__DIR__ . '/../vendor/orchestra/testbench-core/laravel/'));
25+
$appRoot = realpath($this->makeFilePath(__DIR__ . '/../vendor/orchestra/testbench-core/laravel/'));
3026
$putFiles = [];
3127
$filesystem->shouldReceive('put')->withArgs(function ($path, $content) use (&$putFiles, $appRoot) {
32-
$putFiles[] = makeFilePath(str_replace($appRoot, '', $path));
28+
$putFiles[] = $this->makeFilePath(str_replace($appRoot, '', $path));
3329

3430
return true;
3531
});
3632

3733
artisan(GenerateServer::class);
3834

39-
$needFiles = [
40-
makeFilePath('/app/Http/ApiV1/OpenApiGenerated/routes.php'),
35+
assertEqualsCanonicalizing([
36+
$this->makeFilePath('/app/Http/ApiV1/OpenApiGenerated/routes.php'),
4137

42-
makeFilePath('/app/Http/Controllers/ResourcesController.php'),
43-
makeFilePath('/app/Http/Requests/TestFullGenerateRequest.php'),
44-
makeFilePath('/app/Http/Tests/ResourcesComponentTest.php'),
45-
makeFilePath('/app/Http/Requests/TestFooRenameRequest.php'),
38+
$this->makeFilePath('/app/Http/Controllers/ResourcesController.php'),
39+
$this->makeFilePath('/app/Http/Requests/TestFullGenerateRequest.php'),
40+
$this->makeFilePath('/app/Http/Tests/ResourcesComponentTest.php'),
41+
$this->makeFilePath('/app/Http/Requests/TestFooRenameRequest.php'),
4642

47-
makeFilePath('/app/Http/Controllers/WithoutResponsesController.php'),
43+
$this->makeFilePath('/app/Http/Controllers/WithoutResponsesController.php'),
4844

49-
makeFilePath('/WithoutNamespaceController.php'),
50-
makeFilePath('/WithoutNamespaceRequest.php'),
51-
makeFilePath('/WithoutNamespaceComponentTest.php'),
45+
$this->makeFilePath('/WithoutNamespaceController.php'),
46+
$this->makeFilePath('/WithoutNamespaceRequest.php'),
47+
$this->makeFilePath('/WithoutNamespaceComponentTest.php'),
5248

53-
makeFilePath('/app/Http/ApiV1/OpenApiGenerated/Enums/TestIntegerEnum.php'),
54-
makeFilePath('/app/Http/ApiV1/OpenApiGenerated/Enums/TestStringEnum.php'),
55-
];
56-
sort($needFiles);
57-
sort($putFiles);
58-
assertEquals($needFiles, $putFiles);
49+
$this->makeFilePath('/app/Http/ApiV1/OpenApiGenerated/Enums/TestIntegerEnum.php'),
50+
$this->makeFilePath('/app/Http/ApiV1/OpenApiGenerated/Enums/TestStringEnum.php'),
51+
], $putFiles);
5952
});

tests/TestCase.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ protected function getPackageProviders($app)
1414
];
1515
}
1616

17+
public function makeFilePath(string $path): string
18+
{
19+
return str_replace('/', DIRECTORY_SEPARATOR, $path);
20+
}
21+
1722
public function getEnvironmentSetUp($app)
1823
{
1924
config()->set('database.default', 'testing');

0 commit comments

Comments
 (0)