|
@@ -869,7 +869,15 @@ class FormTest extends \PHPUnit_Framework_TestCase
|
|
|
{
|
|
|
$test = $this;
|
|
|
$type1 = $this->getMock('Symfony\Component\Form\FormTypeInterface');
|
|
|
+ $type1Extension = $this->getMock('Symfony\Component\Form\FormTypeExtensionInterface');
|
|
|
+ $type1->expects($this->any())
|
|
|
+ ->method('getExtensions')
|
|
|
+ ->will($this->returnValue(array($type1Extension)));
|
|
|
$type2 = $this->getMock('Symfony\Component\Form\FormTypeInterface');
|
|
|
+ $type2Extension = $this->getMock('Symfony\Component\Form\FormTypeExtensionInterface');
|
|
|
+ $type2->expects($this->any())
|
|
|
+ ->method('getExtensions')
|
|
|
+ ->will($this->returnValue(array($type2Extension)));
|
|
|
$calls = array();
|
|
|
|
|
|
$type1->expects($this->once())
|
|
@@ -880,6 +888,14 @@ class FormTest extends \PHPUnit_Framework_TestCase
|
|
|
$test->assertFalse($view->hasChildren());
|
|
|
}));
|
|
|
|
|
|
+ $type1Extension->expects($this->once())
|
|
|
+ ->method('buildView')
|
|
|
+ ->will($this->returnCallback(function (FormView $view, Form $form) use ($test, &$calls) {
|
|
|
+ $calls[] = 'type1ext::buildView';
|
|
|
+ $test->assertTrue($view->hasParent());
|
|
|
+ $test->assertFalse($view->hasChildren());
|
|
|
+ }));
|
|
|
+
|
|
|
$type2->expects($this->once())
|
|
|
->method('buildView')
|
|
|
->will($this->returnCallback(function (FormView $view, Form $form) use ($test, &$calls) {
|
|
@@ -888,6 +904,14 @@ class FormTest extends \PHPUnit_Framework_TestCase
|
|
|
$test->assertFalse($view->hasChildren());
|
|
|
}));
|
|
|
|
|
|
+ $type2Extension->expects($this->once())
|
|
|
+ ->method('buildView')
|
|
|
+ ->will($this->returnCallback(function (FormView $view, Form $form) use ($test, &$calls) {
|
|
|
+ $calls[] = 'type2ext::buildView';
|
|
|
+ $test->assertTrue($view->hasParent());
|
|
|
+ $test->assertFalse($view->hasChildren());
|
|
|
+ }));
|
|
|
+
|
|
|
$type1->expects($this->once())
|
|
|
->method('buildViewBottomUp')
|
|
|
->will($this->returnCallback(function (FormView $view, Form $form) use ($test, &$calls) {
|
|
@@ -895,6 +919,13 @@ class FormTest extends \PHPUnit_Framework_TestCase
|
|
|
$test->assertTrue($view->hasChildren());
|
|
|
}));
|
|
|
|
|
|
+ $type1Extension->expects($this->once())
|
|
|
+ ->method('buildViewBottomUp')
|
|
|
+ ->will($this->returnCallback(function (FormView $view, Form $form) use ($test, &$calls) {
|
|
|
+ $calls[] = 'type1ext::buildViewBottomUp';
|
|
|
+ $test->assertTrue($view->hasChildren());
|
|
|
+ }));
|
|
|
+
|
|
|
$type2->expects($this->once())
|
|
|
->method('buildViewBottomUp')
|
|
|
->will($this->returnCallback(function (FormView $view, Form $form) use ($test, &$calls) {
|
|
@@ -902,6 +933,13 @@ class FormTest extends \PHPUnit_Framework_TestCase
|
|
|
$test->assertTrue($view->hasChildren());
|
|
|
}));
|
|
|
|
|
|
+ $type2Extension->expects($this->once())
|
|
|
+ ->method('buildViewBottomUp')
|
|
|
+ ->will($this->returnCallback(function (FormView $view, Form $form) use ($test, &$calls) {
|
|
|
+ $calls[] = 'type2ext::buildViewBottomUp';
|
|
|
+ $test->assertTrue($view->hasChildren());
|
|
|
+ }));
|
|
|
+
|
|
|
$form = $this->getBuilder()->setTypes(array($type1, $type2))->getForm();
|
|
|
$form->setParent($this->getBuilder()->getForm());
|
|
|
$form->add($this->getBuilder()->getForm());
|
|
@@ -910,9 +948,13 @@ class FormTest extends \PHPUnit_Framework_TestCase
|
|
|
|
|
|
$this->assertEquals(array(
|
|
|
0 => 'type1::buildView',
|
|
|
- 1 => 'type2::buildView',
|
|
|
- 2 => 'type1::buildViewBottomUp',
|
|
|
- 3 => 'type2::buildViewBottomUp',
|
|
|
+ 1 => 'type1ext::buildView',
|
|
|
+ 2 => 'type2::buildView',
|
|
|
+ 3 => 'type2ext::buildView',
|
|
|
+ 4 => 'type1::buildViewBottomUp',
|
|
|
+ 5 => 'type1ext::buildViewBottomUp',
|
|
|
+ 6 => 'type2::buildViewBottomUp',
|
|
|
+ 7 => 'type2ext::buildViewBottomUp',
|
|
|
), $calls);
|
|
|
}
|
|
|
|