-
-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Labels
BugConfirmed bugs or bugfixes.Confirmed bugs or bugfixes.
Description
Symfony: 4.3.2
Sylius: 1.5.2
PHP: 7.3.7
Consider this fixture
<?php
declare(strict_types=1);
namespace HBX\Fixture;
use Sylius\Bundle\CoreBundle\Fixture\AbstractResourceFixture;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
class ProductFixture extends AbstractResourceFixture
{
public function getName(): string
{
return 'product';
}
protected function configureResourceNode(ArrayNodeDefinition $resourceNode): void
{
$resourceNode
->arrayNode('product_options')->scalarPrototype()->end()->end()
;
}
}In ProductExampleFactory
<?php
namespace App\Fixture\Factory;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
class ProductExampleFactory extends SyliusProductExampleFactory
{
protected function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver);
$resolver
// ...
// Never run
->setDefault('product_options', function (Options $options): array {
$productOptions = $this->productOptionRepository->findAll();
return [$productOptions[rand(0, count($productOptions) - 1)]];
})
// Actually even you set the default value direct, the resolved value is still an empty array only
// ->setDefault('product_options', ['Wow'])
;
}
}I am not sure it is a SyliusFixtureBundle's bug or Symfony 4.3.3's bug
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugConfirmed bugs or bugfixes.Confirmed bugs or bugfixes.