This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/tests/Symfony/Tests/Component/Form/Renderer/Plugin/ParentNamePluginTest.php

67 lines
2.2 KiB
PHP
Raw Normal View History

2011-03-22 20:51:19 +00:00
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Tests\Component\Form\Renderer\Plugin;
use Symfony\Component\Form\Renderer\Plugin\ParentNamePlugin;
class ParentNamePluginTest extends \PHPUnit_Framework_TestCase
{
public function testSetUpHasParent()
{
2011-03-22 22:19:51 +00:00
$parentRenderer = $this->getMock('Symfony\Component\Form\Renderer\FormRendererInterface');
2011-03-22 20:51:19 +00:00
$parentRenderer->expects($this->once())
->method('getVar')
->will($this->returnValue("parentName"));
2011-03-22 22:19:51 +00:00
$parentField = $this->getMock('Symfony\Tests\Component\Form\FormInterface');
2011-03-22 20:51:19 +00:00
$parentField->expects($this->once())
->method('getRenderer')
->will($this->returnValue($parentRenderer));
2011-03-22 22:19:51 +00:00
$field = $this->getMock('Symfony\Tests\Component\Form\FormInterface');
2011-03-22 20:51:19 +00:00
$field->expects($this->once())
->method('getParent')
->will($this->returnValue($parentField));
$field->expects($this->once())
->method('hasParent')
->will($this->returnValue(true));
2011-03-22 22:19:51 +00:00
$renderer = $this->getMock('Symfony\Component\Form\Renderer\FormRendererInterface');
2011-03-22 20:51:19 +00:00
$renderer->expects($this->once())
->method('setVar')
->with($this->equalTo('name'), $this->equalTo('parentName'));
2011-03-22 22:19:51 +00:00
$plugin = new ParentNamePlugin();
$plugin->setUp($field, $renderer);
2011-03-22 20:51:19 +00:00
}
public function testSetUpNoParent()
{
2011-03-22 22:19:51 +00:00
$field = $this->getMock('Symfony\Tests\Component\Form\FormInterface');
2011-03-22 20:51:19 +00:00
$field->expects($this->never())
->method('getParent');
$field->expects($this->once())
->method('hasParent')
->will($this->returnValue(false));
2011-03-22 22:19:51 +00:00
$renderer = $this->getMock('Symfony\Component\Form\Renderer\FormRendererInterface');
2011-03-22 20:51:19 +00:00
$renderer->expects($this->never())
->method('setVar');
2011-03-22 22:19:51 +00:00
$plugin = new ParentNamePlugin();
$plugin->setUp($field, $renderer);
2011-03-22 20:51:19 +00:00
}
}