AbstractExtensionTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  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 Symfony\Component\Form\Tests;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\Form\AbstractExtension;
  13. use Symfony\Component\Form\Tests\Fixtures\FooType;
  14. class AbstractExtensionTest extends TestCase
  15. {
  16. public function testHasType()
  17. {
  18. $loader = new ConcreteExtension();
  19. $this->assertTrue($loader->hasType('Symfony\Component\Form\Tests\Fixtures\FooType'));
  20. $this->assertFalse($loader->hasType('foo'));
  21. }
  22. public function testGetType()
  23. {
  24. $loader = new ConcreteExtension();
  25. $this->assertInstanceOf('Symfony\Component\Form\Tests\Fixtures\FooType', $loader->getType('Symfony\Component\Form\Tests\Fixtures\FooType'));
  26. }
  27. /**
  28. * @expectedException \InvalidArgumentException
  29. * @expectedExceptionMessage Custom resolver "Symfony\Component\Form\Tests\Fixtures\CustomOptionsResolver" must extend "Symfony\Component\OptionsResolver\OptionsResolver".
  30. */
  31. public function testCustomOptionsResolver()
  32. {
  33. $extension = new Fixtures\LegacyFooTypeBarExtension();
  34. $resolver = new Fixtures\CustomOptionsResolver();
  35. $extension->setDefaultOptions($resolver);
  36. }
  37. }
  38. class ConcreteExtension extends AbstractExtension
  39. {
  40. protected function loadTypes()
  41. {
  42. return array(new FooType());
  43. }
  44. protected function loadTypeGuesser()
  45. {
  46. }
  47. }