Skip to content
This repository was archived by the owner on Apr 30, 2019. It is now read-only.

Commit 5fa22f9

Browse files
committed
Test field with mapped => false option isn't mapped by SimpleObjectMapper
1 parent 1d29614 commit 5fa22f9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/Unit/DataMapper/SimpleObjectMapperTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,27 @@ public function testSettingSimpleObjectOnFormWithObjectToFormDataConverter()
191191
$this->assertInstanceOf(Movie::class, $newMedia);
192192
$this->assertSame('bar', $newMedia->getAuthor());
193193
}
194+
195+
public function tesNonMappedField()
196+
{
197+
$builder = $this->factory->createBuilder(FormType::class, new Book('foo'), ['data_class' => Media::class])
198+
->add('author')
199+
->add('mediaType', null, ['mapped' => false])
200+
;
201+
202+
$builder->setDataMapper(new SimpleObjectMapper(new MediaConverter()));
203+
$form = $builder->getForm();
204+
205+
$this->assertSame('foo', $form->get('author')->getData());
206+
$this->assertSame(null, $form->get('mediaType')->getData());
207+
208+
$form->submit(['author' => 'bar', 'mediaType' => 'movie']);
209+
210+
$newMedia = $form->getData();
211+
212+
$this->assertInstanceOf(Movie::class, $newMedia);
213+
$this->assertSame('bar', $newMedia->getAuthor());
214+
}
194215
}
195216

196217
class FormDataToMoneyConverter extends \PHPUnit_Framework_TestCase implements FormDataToObjectConverterInterface

0 commit comments

Comments
 (0)