ModelsToArrayTransformerTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /*
  3. * This file is part of the Sonata Project package.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Sonata\AdminBundle\Tests\Form\DataTransformer;
  11. use Sonata\AdminBundle\Form\DataTransformer\ModelsToArrayTransformer;
  12. class ModelsToArrayTransformerTest extends \PHPUnit_Framework_TestCase
  13. {
  14. private $modelManager;
  15. protected function setUp()
  16. {
  17. $this->modelManager = $this->prophesize('Sonata\AdminBundle\Model\ModelManagerInterface')->reveal();
  18. }
  19. public function testConstructor()
  20. {
  21. $transformer = new ModelsToArrayTransformer(
  22. $this->modelManager,
  23. 'Sonata\AdminBundle\Tests\Fixtures\Entity\Foo'
  24. );
  25. $this->assertInstanceOf('Sonata\AdminBundle\Form\DataTransformer\ModelsToArrayTransformer', $transformer);
  26. }
  27. /**
  28. * @group legacy
  29. */
  30. public function testLegacyConstructor()
  31. {
  32. $choiceListClass = interface_exists('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')
  33. ? 'Sonata\AdminBundle\Form\ChoiceList\ModelChoiceLoader'
  34. : 'Sonata\AdminBundle\Form\ChoiceList\ModelChoiceList'
  35. ;
  36. $choiceList = $this->prophesize($choiceListClass)->reveal();
  37. $transformer = new ModelsToArrayTransformer(
  38. $choiceList,
  39. $this->modelManager,
  40. 'Sonata\AdminBundle\Tests\Fixtures\Entity\Foo'
  41. );
  42. $this->assertInstanceOf('Sonata\AdminBundle\Form\DataTransformer\ModelsToArrayTransformer', $transformer);
  43. }
  44. }