Skip to content

Commit

Permalink
remove default value on boolean node, add new dataset on ExtractorTest
Browse files Browse the repository at this point in the history
  • Loading branch information
JoMessina committed May 27, 2024
1 parent 320bdd5 commit f4e47df
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
4 changes: 0 additions & 4 deletions src/Builder/Capacity/Lookup/All.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ final class All implements Builder
private ?Node\Expr $code = null;
private string $type = '';

public function __construct()
{
}

public function withEndpoint(Node\Expr|Node\Identifier $endpoint): self
{
$this->endpoint = $endpoint;
Expand Down
9 changes: 8 additions & 1 deletion src/Configuration/Extractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@ public function getConfigTreeBuilder(): Config\Definition\Builder\TreeBuilder
&& \in_array($data['type'], ['referenceEntityAttributeOption'], true))
->thenInvalid('The reference_entity option should be used with the "referenceEntityAttributeOption" endpoint.')
->end()
->validate()
->ifTrue(fn ($data) => \array_key_exists('with_enriched_attributes', $data) && \array_key_exists('type', $data) && 'all' !== $data['method'] && \in_array($data['type'], ['category'], true))
->thenInvalid('The with_enriched_attributes option should only be used with the "category" endpoint.')
->end()
->validate()
->ifTrue(fn ($data) => \array_key_exists('with_enriched_attributes', $data) && \array_key_exists('method', $data) && 'all' !== $data['method'])
->thenInvalid('The with_enriched_attributes option should only be used with the "all" method.')
->end()
->children()
->scalarNode('type')
->isRequired()
Expand Down Expand Up @@ -239,7 +247,6 @@ public function getConfigTreeBuilder(): Config\Definition\Builder\TreeBuilder
->end()
->end()
->booleanNode('with_enriched_attributes')
->defaultFalse()
->validate()
->ifTrue(isExpression())
->then(asExpression())
Expand Down
14 changes: 14 additions & 0 deletions tests/functional/Configuration/ExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,20 @@ public static function validDataProvider(): iterable
'search' => [],
],
];
yield [
'config' => [
'method' => 'all',
'type' => 'category',
'search' => [],
'with_enriched_attributes' => true,
],
'expected' => [
'method' => 'all',
'type' => 'category',
'search' => [],
'with_enriched_attributes' => true,
],
];
}

#[\PHPUnit\Framework\Attributes\DataProvider('validDataProvider')]
Expand Down

0 comments on commit f4e47df

Please sign in to comment.