function it_builds_attribute_types_prototype_and_passes_it_as_argument(FormBuilder $builder, FormBuilder $fieldBuilder, FormFactoryInterface $formFactory, ChoiceListInterface $choiceList, AttributeInterface $attribute) { $builder->getFormFactory()->willReturn($formFactory); $builder->add('attribute', 'sylius_server_attribute_choice', Argument::any())->willReturn($builder); $builder->addEventSubscriber(Argument::any())->willReturn($builder); $attribute->getType()->willReturn('checkbox')->shouldBeCalled(); $attribute->getConfiguration()->willReturn(array('label' => 'sylius.form.attribute.server_attribute_value.value'))->shouldBeCalled(); $choiceList->getChoices()->willReturn(array($attribute)); $fieldBuilder->getOption('choice_list')->willReturn($choiceList); $builder->get('attribute')->willReturn($fieldBuilder); $builder->create('value', 'checkbox', array('label' => 'sylius.form.attribute.server_attribute_value.value'))->shouldBeCalled()->willReturn($fieldBuilder); $fieldBuilder->getForm()->willReturn('Form for attribute'); $builder->setAttribute('prototypes', array(0 => 'Form for attribute'))->shouldBeCalled(); $this->buildForm($builder, array()); }
/** * @Then /^(this product attribute) should no longer exist in the registry$/ */ public function thisProductAttributeShouldNoLongerExistInTheRegistry(AttributeInterface $productAttribute) { Assert::false($this->indexPage->isSingleResourceOnPage(['code' => $productAttribute->getCode()]), sprintf('Product attribute %s should no exist in the registry, but it does.', $productAttribute->getName())); }
/** * @param AttributeInterface $productAttribute * * @return mixed */ private function getRandomValueForProductAttribute(AttributeInterface $productAttribute) { switch ($productAttribute->getStorageType()) { case AttributeValueInterface::STORAGE_BOOLEAN: return $this->faker->boolean; case AttributeValueInterface::STORAGE_INTEGER: return $this->faker->numberBetween(0, 10000); case AttributeValueInterface::STORAGE_FLOAT: return $this->faker->randomFloat(4, 0, 10000); case AttributeValueInterface::STORAGE_TEXT: return $this->faker->sentence; case AttributeValueInterface::STORAGE_DATE: case AttributeValueInterface::STORAGE_DATETIME: return $this->faker->dateTimeThisCentury; default: throw new \BadMethodCallException(); } }