Skip to content

Commit

Permalink
WIp
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry committed Nov 22, 2023
1 parent 9dda786 commit 270c933
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 13 deletions.
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/Parallelization/BatchResults.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ public static function createFilename(): string
return unique_id('batch-').'.json';
}

public static function createFileContent(): string
{
return unique_id('batch-').'.json';
}

/**
* @return iterable<SplFileInfo>
*/
Expand Down
49 changes: 49 additions & 0 deletions tests/Parallelization/BatchResultTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace KevinGH\Box\Parallelization;

use Humbug\PhpScoper\Symbol\SymbolsRegistry;
use PhpParser\Node\Name\FullyQualified;
use PHPUnit\Framework\TestCase;

/**
* @covers \KevinGH\Box\Parallelization\BatchResult
*/
final class BatchResultTest extends TestCase
{
/**
* @dataProvider batchResultProvider
*/
public function test_it_can_be_serialized_and_deserialized(BatchResult $batchResult): void
{
$unserializedBatchResult = BatchResult::unserialize($batchResult->serialize());

self::assertEquals($batchResult, $unserializedBatchResult);
}

public static function batchResultProvider(): iterable
{
yield 'empty' => [
new BatchResult(
[],
new SymbolsRegistry(),
),
];

$symbolsRegistry = new SymbolsRegistry();
$symbolsRegistry->recordClass(
new FullyQualified('Box\Func'),
new FullyQualified('Scoped\Box\Func'),
);

yield 'nominal' => [
new BatchResult(
[
'/path/to/file.php',
'<?php echo "Hello world!";'
],
$symbolsRegistry,
),
];
}
}
49 changes: 49 additions & 0 deletions tests/Parallelization/ConfigurationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace KevinGH\Box\Parallelization;

use Humbug\PhpScoper\Symbol\SymbolsRegistry;
use PhpParser\Node\Name\FullyQualified;
use PHPUnit\Framework\TestCase;

/**
* @covers \KevinGH\Box\Parallelization\Configuration
*/
final class ConfigurationTest extends TestCase
{
/**
* @dataProvider configurationProvider
*/
public function test_it_can_be_serialized_and_deserialized(Configuration $configuration): void
{
$unserializedBatchResult = BatchResult::unserialize($configuration->serialize());

self::assertEquals($configuration, $unserializedBatchResult);
}

public static function configurationProvider(): iterable
{
yield 'empty' => [
new BatchResult(
[],
new SymbolsRegistry(),
),
];

$symbolsRegistry = new SymbolsRegistry();
$symbolsRegistry->recordClass(
new FullyQualified('Box\Func'),
new FullyQualified('Scoped\Box\Func'),
);

yield 'nominal' => [
new BatchResult(
[
'/path/to/file.php',
'<?php echo "Hello world!";'
],
$symbolsRegistry,
),
];
}
}
2 changes: 0 additions & 2 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
* with this source code in the file LICENSE.
*/

use Laravel\SerializableClosure\Support\ClosureStream;
use org\bovigo\vfs\vfsStreamWrapper;
use Symfony\Component\Filesystem\Path;
use function KevinGH\Box\register_aliases;
Expand All @@ -21,7 +20,6 @@
register_aliases();

vfsStreamWrapper::register();
ClosureStream::register();

$binBoxPath = Path::normalize(__DIR__.'/../bin/box');

Expand Down

0 comments on commit 270c933

Please sign in to comment.