Example #1
0
 public function addTypeExtension(FormTypeExtensionInterface $extension)
 {
     $type = $extension->getExtendedType();
     if (!isset($this->extensions[$type])) {
         $this->extensions[$type] = array();
     }
     $this->extensions[$type][] = $extension;
 }
Example #2
0
    public function testFinishView()
    {
        $options = array('a' => '1', 'b' => '2');
        $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock();
        $view = $this->getMockBuilder('Symfony\Component\Form\FormView')->getMock();

        $i = 0;

        $assertIndex = function ($index) use (&$i) {
            return function () use (&$i, $index) {
                $this->assertEquals($index, $i, 'Executed at index '.$index);

                ++$i;
            };
        };

        // First the super type
        $this->parentType->expects($this->once())
            ->method('finishView')
            ->with($view, $form, $options)
            ->will($this->returnCallback($assertIndex(0)));

        // Then the type itself
        $this->type->expects($this->once())
            ->method('finishView')
            ->with($view, $form, $options)
            ->will($this->returnCallback($assertIndex(1)));

        // Then its extensions
        $this->extension1->expects($this->once())
            ->method('finishView')
            ->with($view, $form, $options)
            ->will($this->returnCallback($assertIndex(2)));

        $this->extension2->expects($this->once())
            ->method('finishView')
            ->with($view, $form, $options)
            ->will($this->returnCallback($assertIndex(3)));

        $this->resolvedType->finishView($view, $form, $options);
    }