Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect option when adding TaxType to item #982

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/QuoteBundle/Form/Type/ItemType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
58 changes: 58 additions & 0 deletions src/QuoteBundle/Tests/Form/Type/ItemTypeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

/*
* This file is part of SolidInvoice project.
*
* (c) Pierre du Plessis <open-source@solidworx.co>
*
* 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<FormExtensionInterface>
*/
protected function getExtensions(): array
{
$itemType = new ItemType($this->registry);

return [
// register the type instances with the PreloadedExtension
new PreloadedExtension([$itemType], []),
];
}
}
Loading