Skip to content

Commit

Permalink
Merge 0a8722a into d9f3666
Browse files Browse the repository at this point in the history
  • Loading branch information
pierredup committed Nov 22, 2023
2 parents d9f3666 + 0a8722a commit e055e59
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
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], []),
];
}
}

0 comments on commit e055e59

Please sign in to comment.