Skip to content

Commit 1ab0d8e

Browse files
authored
Merge pull request #170 from RonasIT/rguskov/make-mock-parallel-testing-token
Rguskov/make mock parallel testing token
2 parents 204ccec + 744282d commit 1ab0d8e

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

config/auto-doc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
'title' => env('APP_NAME', 'Name of Your Application'),
4848
'termsOfService' => '',
4949
'contact' => [
50-
'email' => null
50+
'email' => null,
5151
],
5252
'license' => [
5353
'name' => '',
@@ -208,7 +208,7 @@
208208
| The waiting time between attempts to write to the temporary documentation file while the file is locked
209209
*/
210210
'wait_time' => 500,
211-
]
211+
],
212212
],
213213

214214
'config_version' => '2.9',

tests/LocalDriverTest.php

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

33
namespace RonasIT\AutoDoc\Tests;
44

5-
use Illuminate\Support\Facades\ParallelTesting;
65
use RonasIT\AutoDoc\Drivers\LocalDriver;
76
use Illuminate\Contracts\Filesystem\FileNotFoundException;
87
use RonasIT\AutoDoc\Exceptions\MissedProductionFilePathException;
@@ -38,11 +37,9 @@ public function testSaveProcessTmpData()
3837

3938
public function testSaveProcessTmpDataCheckTokenBasedPath()
4039
{
41-
$token = 'workerID';
40+
$this->mockParallelTestingToken();
4241

43-
ParallelTesting::resolveTokenUsing(fn () => $token);
44-
45-
$processTempFilePath = __DIR__ . "/../storage/temp_documentation_{$token}.json";
42+
$processTempFilePath = __DIR__ . '/../storage/temp_documentation_workerID.json';
4643

4744
app(LocalDriver::class)->saveProcessTmpData(self::$tmpData);
4845

tests/SwaggerServiceTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace RonasIT\AutoDoc\Tests;
44

55
use Illuminate\Http\Testing\File;
6-
use Illuminate\Support\Facades\ParallelTesting;
76
use PHPUnit\Framework\Attributes\DataProvider;
87
use RonasIT\AutoDoc\Exceptions\EmptyContactEmailException;
98
use RonasIT\AutoDoc\Exceptions\InvalidDriverClassException;
@@ -923,9 +922,7 @@ public function testAddDataDescriptionForRouteConditionals()
923922

924923
public function testMergeTempDocumentation()
925924
{
926-
$token = 'workerID';
927-
928-
ParallelTesting::resolveTokenUsing(fn () => $token);
925+
$this->mockParallelTestingToken();
929926

930927
$tempFilePath = __DIR__ . '/../storage/temp_documentation.json';
931928

tests/TestCase.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Filesystem\Filesystem;
66
use Illuminate\Http\Request;
77
use Illuminate\Support\Arr;
8+
use Illuminate\Support\Facades\ParallelTesting;
89
use Illuminate\Support\Facades\Route;
910
use Illuminate\Testing\TestResponse;
1011
use Orchestra\Testbench\TestCase as BaseTest;
@@ -198,4 +199,9 @@ protected function addGlobalPrefix($prefix = '/global')
198199

199200
$this->setUp();
200201
}
202+
203+
protected function mockParallelTestingToken(string $token = 'workerID'): void
204+
{
205+
ParallelTesting::resolveTokenUsing(fn () => $token);
206+
}
201207
}

0 commit comments

Comments
 (0)