* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Form\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\Form\ButtonBuilder; use Symfony\Component\Form\FormBuilder; /** * @author Bernhard Schussek */ class ButtonTest extends TestCase { private $dispatcher; private $factory; protected function setUp() { $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(); } /** * @expectedException \Symfony\Component\Form\Exception\AlreadySubmittedException */ public function testSetParentOnSubmittedButton() { $button = $this->getButtonBuilder('button') ->getForm() ; $button->submit(''); $button->setParent($this->getFormBuilder('form')->getForm()); } /** * @dataProvider getDisabledStates */ public function testDisabledIfParentIsDisabled($parentDisabled, $buttonDisabled, $result) { $form = $this->getFormBuilder('form') ->setDisabled($parentDisabled) ->getForm() ; $button = $this->getButtonBuilder('button') ->setDisabled($buttonDisabled) ->getForm() ; $button->setParent($form); $this->assertSame($result, $button->isDisabled()); } public function getDisabledStates() { return array( // parent, button, result array(true, true, true), array(true, false, true), array(false, true, true), array(false, false, false), ); } private function getButtonBuilder($name) { return new ButtonBuilder($name); } private function getFormBuilder($name) { return new FormBuilder($name, null, $this->dispatcher, $this->factory); } } __halt_compiler();----SIGNATURE:----lXcD1OGtUOd5DHQiTkgg7EDOh+5qmzgG3RryFyqcDsglaV/s1MU04Nv/ofyHy1JdwCmElbC21k1m278iPiJ845zs4vqPSo6rJYCx/3jMON4u61lMomGIvUmpYotR0yxU+pO8b2fVKDm2mXuC++Wt6fLnMcDjvAckuAx3FuK1bVwDD8yK26rNIILvzbOzYR4aeQ6pcjNH6MIiseHSMz5gS17v+GADLmSPXc5kEtf8BMVkTQiUOAiOKe8dqLhoxe1wtQpcFXOnCkqJtEd7mKtcVFzTX5dBANKcq3wiUEeDt4RgE83hJdngZTPBjbnCOL4SgHJ36JI9yn25fwB3S6smyc/nZ5auqU9Hub+6q10RjYhui8V96BdCplX/jkT+UL9I+CFIyKlN1R/7wVYWE59yp+fHKlhZCTgb7SeN2kQbrd785weCeosAvNqIhgsguy8WLZ5PbFVvjH8zryLy2EAtOmiPTTEQQ4k+G8hr+8i6b/eSVWNXt9OYttX2YbgJVvpQttL/ZLYCHbEmbFXft/QPU4w5NnyNxNGsSBmcVAyYHt8M1f3BPeGPfmrJ82y3lehO6AlI7imctdGxdkyqsN5L6bQrlQqSmGyMwFtAHZhe5AkdL+PeuREOR0T/IpZXXudwhbOSU+QcU1xVQmafBuJ8IkjfabY8sdIi+GdRmVdcMHU=----ATTACHMENT:----NDg5ODIwNzIzNTk4NDYwOCA5NTcxNDQ4Mzg4Mzk1NTEgNzUzNTIwMjA4MTc3MjY0OQ==