ThemeRendererTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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\Renderer;
  11. use Symfony\Component\Form\Renderer\ThemeRenderer;
  12. class ThemeRendererTest extends \PHPUnit_Framework_TestCase
  13. {
  14. protected function createThemeFactory()
  15. {
  16. $themeFactory = $this->getMock('Symfony\Component\Form\Renderer\Theme\FormThemeFactoryInterface');
  17. $themeFactory->expects($this->once())
  18. ->method('create')
  19. ->will($this->returnValue($this->getMock('Symfony\Component\Form\Renderer\Theme\FormThemeInterface')));
  20. return $themeFactory;
  21. }
  22. public function testArrayAccess()
  23. {
  24. $themeFactory = $this->createThemeFactory();
  25. $renderer = new ThemeRenderer($themeFactory);
  26. $renderer->setVar('fields', array('foo' => 'baz', 'bar' => 'baz'));
  27. $this->assertTrue(isset($renderer['foo']));
  28. $this->assertTrue(isset($renderer['bar']));
  29. $this->assertEquals('baz', $renderer['bar']);
  30. }
  31. public function testIterator()
  32. {
  33. $themeFactory = $this->createThemeFactory();
  34. $renderer = new ThemeRenderer($themeFactory);
  35. $renderer->setVar('fields', array('foo' => 'baz', 'bar' => 'baz'));
  36. foreach ($renderer AS $child) {
  37. $this->assertEquals('baz', $child);
  38. }
  39. }
  40. }