Initial release

This commit is contained in:
Matias Navarro Carter
2018-08-08 14:11:11 -04:00
parent 05871cb847
commit 33eeec319b
18 changed files with 552 additions and 79 deletions

View File

@@ -0,0 +1,41 @@
<?php
/*
* This file is part of the MNC\ChileanRut library.
*
* (c) Matías Navarro Carter <mnavarrocarter@gmail.com>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace MNC\ChileanRut\Tests\Bridge\Symfony\Form;
use MNC\ChileanRut\Bridge\Symfony\Form\RutType;
use MNC\ChileanRut\Rut;
use Symfony\Component\Form\Test\TypeTestCase;
class RutTypeTest extends TypeTestCase
{
public function testSubmitValidData()
{
$objectToCompare = new Rut('16.894.365-2');
// $objectToCompare will retrieve data from the form submission; pass it as the second argument
$form = $this->factory->create(RutType::class);
// submit the data to the form directly
$form->submit('16.894.365-2');
$this->assertTrue($form->isSynchronized());
$formData = $form->getData();
// check that $objectToCompare was modified as expected when the form was submitted
$this->assertInstanceOf(Rut::class, $formData);
$this->assertTrue($formData->isEqualTo($objectToCompare));
$view = $form->createView();
$this->assertSame('16.894.365-2', $view->vars['value']);
}
}