AbstractExtensionTest.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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\Tests\Component\Form;
  11. use Symfony\Component\Form\AbstractExtension;
  12. use Symfony\Component\Form\FormTypeInterface;
  13. use Symfony\Component\Form\FormInterface;
  14. use Symfony\Component\Form\FormView;
  15. use Symfony\Component\Form\FormFactoryInterface;
  16. use Symfony\Component\Form\FormBuilder;
  17. class AbstractExtensionTest extends \PHPUnit_Framework_TestCase
  18. {
  19. public function testHasType()
  20. {
  21. $loader = new TestExtension();
  22. $this->assertTrue($loader->hasType('foo'));
  23. $this->assertFalse($loader->hasType('bar'));
  24. }
  25. public function testGetType()
  26. {
  27. $loader = new TestExtension(array($type));
  28. $this->assertInstanceOf(__NAMESPACE__.'\TestType', $loader->getType('foo'));
  29. $this->assertSame($loader->getType('foo'), $loader->getType('foo'));
  30. }
  31. }
  32. class TestType implements FormTypeInterface
  33. {
  34. public function getName()
  35. {
  36. return 'foo';
  37. }
  38. function buildForm(FormBuilder $builder, array $options) {}
  39. function buildView(FormView $view, FormInterface $form) {}
  40. function buildViewBottomUp(FormView $view, FormInterface $form) {}
  41. function createBuilder($name, FormFactoryInterface $factory, array $options) {}
  42. function getDefaultOptions(array $options) {}
  43. function getParent(array $options) {}
  44. function setExtensions(array $extensions) {}
  45. function getExtensions() {}
  46. }
  47. class TestExtension extends AbstractExtension
  48. {
  49. protected function loadTypes()
  50. {
  51. return array(new TestType());
  52. }
  53. protected function loadTypeGuesser()
  54. {
  55. }
  56. }