diff --git a/src/QuoteBundle/Form/Type/ItemType.php b/src/QuoteBundle/Form/Type/ItemType.php index 8d5be644c..1f6c2d35c 100644 --- a/src/QuoteBundle/Form/Type/ItemType.php +++ b/src/QuoteBundle/Form/Type/ItemType.php @@ -73,7 +73,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'tax', TaxEntityType::class, [ - 'class' => Tax::class, 'placeholder' => 'No Tax', 'attr' => [ 'class' => 'select2 input-mini quote-item-tax', diff --git a/src/QuoteBundle/Tests/Form/Type/ItemTypeTest.php b/src/QuoteBundle/Tests/Form/Type/ItemTypeTest.php new file mode 100644 index 000000000..d4834a3c0 --- /dev/null +++ b/src/QuoteBundle/Tests/Form/Type/ItemTypeTest.php @@ -0,0 +1,58 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace SolidInvoice\QuoteBundle\Tests\Form\Type; + +use Money\Currency; +use Money\Money; +use SolidInvoice\CoreBundle\Tests\FormTestCase; +use SolidInvoice\QuoteBundle\Entity\Item; +use SolidInvoice\QuoteBundle\Form\Type\ItemType; +use Symfony\Component\Form\FormExtensionInterface; +use Symfony\Component\Form\PreloadedExtension; + +final class ItemTypeTest extends FormTestCase +{ + public function testSubmit(): void + { + $description = $this->faker->text; + $price = $this->faker->randomNumber(3); + $qty = $this->faker->randomFloat(2); + + $formData = [ + 'description' => $description, + 'price' => $price, + 'qty' => $qty, + ]; + + $currency = new Currency('USD'); + + $object = new Item(); + $object->setDescription($description); + $object->setQty($qty); + $object->setPrice(new Money($price * 100, $currency)); + + $this->assertFormData($this->factory->create(ItemType::class, null, ['currency' => $currency]), $formData, $object); + } + + /** + * @return array + */ + protected function getExtensions(): array + { + $itemType = new ItemType($this->registry); + + return [ + // register the type instances with the PreloadedExtension + new PreloadedExtension([$itemType], []), + ]; + } +}