Created
February 28, 2011 16:36
-
-
Save johnwards/847573 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Symfony\Tests\Component\Form\Renderer\Plugin; | |
use Symfony\Component\Form\Renderer\Plugin\ValuePlugin; | |
use Symfony\Component\Form\Renderer\DefaultRenderer; | |
use Symfony\Component\Form\FieldInterface; | |
class ValuePluginTest extends \PHPUnit_Framework_TestCase | |
{ | |
public function testSetUpSetsValue() | |
{ | |
$field = $this->createMockField("simpleField", "value to copy"); | |
$renderer = $this->createMockRenderer(); | |
$plugin = new ValuePlugin($field); | |
$plugin->setUp($renderer); | |
$this->assertEquals("value to copy", $renderer->getVar("value")); | |
} | |
protected function createMockField($key,$value) | |
{ | |
$field = $this->getMock( | |
'Symfony\Component\Form\FieldInterface', | |
array(), | |
array(), | |
'', | |
false, // don't use constructor | |
false // don't call parent::__clone | |
); | |
$field->expects($this->any()) | |
->method('getKey') | |
->will($this->returnValue($key)); | |
$field->expects($this->any()) | |
->method('getDisplayedData') | |
->will($this->returnValue($value)); | |
return $field; | |
} | |
protected function createMockRenderer() | |
{ | |
$renderer = $this->getMock( | |
'Symfony\Component\Form\Renderer\DefaultRenderer', | |
array(), | |
array(), | |
'', | |
false, // don't use constructor | |
false // don't call parent::__clone | |
); | |
return $renderer; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment