Skip to content

Commit 88da32b

Browse files
committed
Fixed code building path handling
1 parent 4553e22 commit 88da32b

7 files changed

+41
-2
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
},
3434
"extra": {
3535
"branch-alias": {
36-
"dev-main": "0.2.x-dev"
36+
"dev-main": "0.4.x-dev"
3737
}
3838
}
3939
}

src/Assert/BuilderAssertTrait.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Kiboko\Component\PHPUnitExtension\Assert;
4+
5+
trait BuilderAssertTrait
6+
{
7+
abstract protected function getBuilderCompilePath(): string;
8+
}

src/Assert/ExtractorBuilderAssertTrait.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@
1313

1414
trait ExtractorBuilderAssertTrait
1515
{
16+
use BuilderAssertTrait;
17+
1618
abstract public static function assertThat($value, Constraint $constraint, string $message = ''): void;
1719
abstract public function pipelineRunner(): PipelineRunnerInterface;
1820

1921
protected function assertBuildsExtractorExtractsLike(iterable $expected, DefaultBuilder $builder, string $message = '')
2022
{
2123
$this->assertThat($builder, new BuilderProducesCodeThat(
24+
$this->getBuilderCompilePath(),
2225
new PipelineExtractsLike($expected, fn ($item) => new IsEqual($item), $this->pipelineRunner())
2326
), $message);
2427
}
@@ -27,6 +30,7 @@ protected function assertBuildsExtractorDoesNotExtractLike(iterable $expected, D
2730
{
2831
$this->assertThat($builder, new LogicalNot(
2932
new BuilderProducesCodeThat(
33+
$this->getBuilderCompilePath(),
3034
new PipelineExtractsLike($expected, fn ($item) => new IsEqual($item), $this->pipelineRunner())
3135
),
3236
), $message);
@@ -35,6 +39,7 @@ protected function assertBuildsExtractorDoesNotExtractLike(iterable $expected, D
3539
protected function assertBuildsExtractorExtractsExactly(iterable $expected, DefaultBuilder $builder, string $message = '')
3640
{
3741
$this->assertThat($builder, new BuilderProducesCodeThat(
42+
$this->getBuilderCompilePath(),
3843
new PipelineExtractsLike($expected, fn ($item) => new IsIdentical($item), $this->pipelineRunner())
3944
), $message);
4045
}
@@ -43,6 +48,7 @@ protected function assertBuildsExtractorDoesNotExtractExactly(iterable $expected
4348
{
4449
$this->assertThat($builder, new LogicalNot(
4550
new BuilderProducesCodeThat(
51+
$this->getBuilderCompilePath(),
4652
new PipelineExtractsLike($expected, fn ($item) => new IsIdentical($item), $this->pipelineRunner())
4753
),
4854
), $message);

src/Assert/LoaderBuilderAssertTrait.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@
1414

1515
trait LoaderBuilderAssertTrait
1616
{
17+
use BuilderAssertTrait;
18+
1719
abstract public static function assertThat($value, Constraint $constraint, string $message = ''): void;
1820
abstract public function pipelineRunner(): PipelineRunnerInterface;
1921

2022
protected function assertBuildsLoaderLoadsLike(iterable $expected, iterable $input, DefaultBuilder $builder, string $message = '')
2123
{
2224
$this->assertThat($builder, new BuilderProducesCodeThat(
25+
$this->getBuilderCompilePath(),
2326
new PipelineLoadsLike($expected, $input, fn ($item) => new IsEqual($item), $this->pipelineRunner())
2427
), $message);
2528
}
@@ -28,6 +31,7 @@ protected function assertBuildsLoaderDoesNotLoadLike(iterable $expected, iterabl
2831
{
2932
$this->assertThat($builder, new LogicalNot(
3033
new BuilderProducesCodeThat(
34+
$this->getBuilderCompilePath(),
3135
new PipelineLoadsLike($expected, $input, fn ($item) => new IsEqual($item), $this->pipelineRunner())
3236
),
3337
), $message);
@@ -36,6 +40,7 @@ protected function assertBuildsLoaderDoesNotLoadLike(iterable $expected, iterabl
3640
protected function assertBuildsLoaderLoadsExactly(iterable $expected, iterable $input, DefaultBuilder $builder, string $message = '')
3741
{
3842
$this->assertThat($builder, new BuilderProducesCodeThat(
43+
$this->getBuilderCompilePath(),
3944
new PipelineLoadsLike($expected, $input, fn ($item) => new IsIdentical($item), $this->pipelineRunner())
4045
), $message);
4146
}
@@ -44,6 +49,7 @@ protected function assertBuildsLoaderDoesNotLoadExactly(iterable $expected, iter
4449
{
4550
$this->assertThat($builder, new LogicalNot(
4651
new BuilderProducesCodeThat(
52+
$this->getBuilderCompilePath(),
4753
new PipelineLoadsLike($expected, $input, fn ($item) => new IsIdentical($item), $this->pipelineRunner())
4854
),
4955
), $message);
@@ -52,6 +58,7 @@ protected function assertBuildsLoaderDoesNotLoadExactly(iterable $expected, iter
5258
protected function assertBuildsLoaderProducesFile(string $expected, iterable $input, DefaultBuilder $builder, string $message = '')
5359
{
5460
$this->assertThat($builder, new BuilderProducesCodeThat(
61+
$this->getBuilderCompilePath(),
5562
new PipelineWritesFile($input, $expected, $this->pipelineRunner()),
5663
), $message);
5764
}
@@ -60,6 +67,7 @@ protected function assertBuildsLoaderDoesNotProduceFile(string $expected, iterab
6067
{
6168
$this->assertThat($builder, new LogicalNot(
6269
new BuilderProducesCodeThat(
70+
$this->getBuilderCompilePath(),
6371
new PipelineWritesFile($input, $expected, $this->pipelineRunner()),
6472
),
6573
), $message);

src/Assert/PipelineBuilderAssertTrait.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@
1010

1111
trait PipelineBuilderAssertTrait
1212
{
13+
use BuilderAssertTrait;
14+
1315
abstract public static function assertThat($value, Constraint $constraint, string $message = ''): void;
1416

1517
protected function assertBuilderProducesInstanceOf(string $expected, DefaultBuilder $builder, string $message = '')
1618
{
1719
$this->assertThat($builder, new BuilderProducesCodeThat(
20+
$this->getBuilderCompilePath(),
1821
new IsInstanceOf($expected)
1922
), $message);
2023
}
@@ -23,6 +26,7 @@ protected function assertBuilderProducesNotInstanceOf(string $expected, DefaultB
2326
{
2427
$this->assertThat($builder, new LogicalNot(
2528
new BuilderProducesCodeThat(
29+
$this->getBuilderCompilePath(),
2630
new IsInstanceOf($expected)
2731
),
2832
), $message);

src/Assert/TransformerBuilderAssertTrait.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@
1313

1414
trait TransformerBuilderAssertTrait
1515
{
16+
use BuilderAssertTrait;
17+
1618
abstract public static function assertThat($value, Constraint $constraint, string $message = ''): void;
1719
abstract public function pipelineRunner(): PipelineRunnerInterface;
1820

1921
protected function assertBuildsTransformerTransformsLike(iterable $expected, iterable $input, DefaultBuilder $builder, string $message = '')
2022
{
2123
$this->assertThat($builder, new BuilderProducesCodeThat(
24+
$this->getBuilderCompilePath(),
2225
new PipelineTransformsLike($expected, $input, fn ($item) => new IsEqual($item), $this->pipelineRunner())
2326
), $message);
2427
}
@@ -27,6 +30,7 @@ protected function assertBuildsTransformerDoesNotTransformLike(iterable $expecte
2730
{
2831
$this->assertThat($builder, new LogicalNot(
2932
new BuilderProducesCodeThat(
33+
$this->getBuilderCompilePath(),
3034
new PipelineTransformsLike($expected, $input, fn ($item) => new IsEqual($item), $this->pipelineRunner())
3135
),
3236
), $message);
@@ -35,6 +39,7 @@ protected function assertBuildsTransformerDoesNotTransformLike(iterable $expecte
3539
protected function assertBuildsTransformerTransformsExactly(iterable $expected, iterable $input, DefaultBuilder $builder, string $message = '')
3640
{
3741
$this->assertThat($builder, new BuilderProducesCodeThat(
42+
$this->getBuilderCompilePath(),
3843
new PipelineTransformsLike($expected, $input, fn ($item) => new IsIdentical($item), $this->pipelineRunner())
3944
), $message);
4045
}
@@ -43,6 +48,7 @@ protected function assertBuildsTransformerDoesNotTransformExactly(iterable $expe
4348
{
4449
$this->assertThat($builder, new LogicalNot(
4550
new BuilderProducesCodeThat(
51+
$this->getBuilderCompilePath(),
4652
new PipelineTransformsLike($expected, $input, fn ($item) => new IsIdentical($item), $this->pipelineRunner())
4753
),
4854
), $message);

src/Constraint/Builder/BuilderProducesCodeThat.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010

1111
final class BuilderProducesCodeThat extends UnaryOperator
1212
{
13+
public function __construct(
14+
private string $builderCompilePath,
15+
$constraint,
16+
) {
17+
parent::__construct($constraint);
18+
}
19+
1320
/**
1421
* Evaluates the constraint for parameter $other. Returns true if the
1522
* constraint is met, false otherwise.
@@ -52,7 +59,7 @@ protected function matches($other): bool
5259

5360
private function createFile(): string
5461
{
55-
return 'vfs://' . hash('sha512', random_bytes(512)) .'.php';
62+
return $this->builderCompilePath . '/' . hash('sha512', random_bytes(512)) .'.php';
5663
}
5764

5865
public function operator(): string

0 commit comments

Comments
 (0)