Skip to content

Commit

Permalink
Removed parallel command calls
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-helldar committed Mar 15, 2024
1 parent 614a072 commit 7fad5b5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 26 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
},
"scripts": {
"test": [
"vendor/bin/pest --parallel"
"vendor/bin/pest"
]
}
}
26 changes: 17 additions & 9 deletions tests/Helpers/data.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,24 @@

declare(strict_types=1);

expect()->extend('toBeDataContains', function () {
foreach (allTableNames() as $table) {
expect($this->value)
->toContain(tableName($table))
->toContain(columnName($table));
expect()->extend('toBeDataContains', function (string $name) {
expect($this->value)
->toContain(tableName($name))
->toContain(columnName($name));

circleProcess(
fn (int $i) => expect($this->value)->toContain(valueName($name, $i))
);
});

expect()->extend('notToBeDataContains', function (string $name) {
expect($this->value)
->toContain(tableName($name))
->toContain(columnName($name));

circleProcess(
fn (int $i) => expect($this->value)->toContain(valueName($table, $i))
);
}
circleProcess(
fn (int $i) => expect($this->value)->not->toContain(valueName($name, $i))
);
});

expect()->extend('toBeContainsMigrations', function () {
Expand Down
15 changes: 4 additions & 11 deletions tests/Helpers/path.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,23 @@

declare(strict_types=1);

use Illuminate\Support\Facades\ParallelTesting;

function dumpStoragePath(): string
{
return dumpPath('dump', 'sql');
return dumpPath('dump.sql');
}

function databasePath(): string
{
return dumpPath('database', 'sqlite');
return dumpPath('database.sqlite');
}

function dumpPath(string $name, string $extension): string
function dumpPath(string $name): string
{
$path = __DIR__ . '/../tmp/' . $name . '-' . processIndex() . '.' . $extension;
$path = __DIR__ . '/../tmp/' . $name;

if (!is_dir($directory = dirname($path))) {
mkdir($directory);
}

return $path;
}

function processIndex(): int
{
return (int)ParallelTesting::token();
}
10 changes: 5 additions & 5 deletions tests/Unit/DumpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

artisan(DumpCommand::class, ['--path' => $path])->run();

$content = file_get_contents($path);

expect($content)
->toBeDataContains()
->toBeContainsMigrations();
expect(file_get_contents($path))
->toBeContainsMigrations()
->toBeDataContains('foo')
->toBeDataContains('bar')
->notToBeDataContains('baz');
});

0 comments on commit 7fad5b5

Please sign in to comment.