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/FieldPluginTest.php

98 lines
3.1 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\FieldPlugin;
class FieldPluginTest extends \PHPUnit_Framework_TestCase
{
public function testSetUp()
{
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->any())
2011-03-22 22:19:51 +00:00
->method('getClientData')
2011-03-22 20:51:19 +00:00
->will($this->returnValue('bar'));
$field->expects($this->any())
->method('hasParent')
->will($this->returnValue(false));
$field->expects($this->any())
2011-03-22 22:19:51 +00:00
->method('getName')
->will($this->returnValue('The_Name'));
2011-03-22 20:51:19 +00:00
$field->expects($this->any())
->method('getErrors')
->will($this->returnValue('someerrors'));
$field->expects($this->any())
->method('isDisabled')
->will($this->returnValue(false));
$field->expects($this->any())
->method('isRequired')
->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->at(0))
->method('setVar')
2011-03-22 22:19:51 +00:00
->with($this->equalTo('renderer'), $this->equalTo($renderer));
2011-03-22 20:51:19 +00:00
$renderer->expects($this->at(1))
->method('setVar')
2011-03-22 22:19:51 +00:00
->with($this->equalTo('id'), $this->equalTo('The_Name'));
2011-03-22 20:51:19 +00:00
$renderer->expects($this->at(2))
->method('setVar')
2011-03-22 22:19:51 +00:00
->with($this->equalTo('name'), $this->equalTo('The_Name'));
2011-03-22 20:51:19 +00:00
$renderer->expects($this->at(3))
->method('setVar')
->with($this->equalTo('errors'), $this->equalTo('someerrors'));
$renderer->expects($this->at(4))
->method('setVar')
->with($this->equalTo('value'), $this->equalTo('bar'));
$renderer->expects($this->at(5))
->method('setVar')
->with($this->equalTo('disabled'), $this->equalTo(false));
$renderer->expects($this->at(6))
->method('setVar')
->with($this->equalTo('required'), $this->equalTo(true));
$renderer->expects($this->at(7))
->method('setVar')
->with($this->equalTo('class'), $this->equalTo(null));
$renderer->expects($this->at(8))
->method('setVar')
->with($this->equalTo('max_length'), $this->equalTo(null));
$renderer->expects($this->at(9))
->method('setVar')
->with($this->equalTo('size'), $this->equalTo(null));
$renderer->expects($this->at(10))
->method('setVar')
2011-03-22 22:19:51 +00:00
->with($this->equalTo('label'), $this->equalTo('The name'));
2011-03-22 20:51:19 +00:00
2011-03-22 22:19:51 +00:00
$plugin = new FieldPlugin();
$plugin->setUp($field, $renderer);
2011-03-22 20:51:19 +00:00
}
}