* * 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:----ePdnl0pl7V8fXogm2mwcgDIq9R/oktLoN8MNbsodtNZVY7fHhWialzmAEBXET7PwmojiwVnsUDXOBF2vV+o5Pns5AklogJvlqpTK1KXctaOmoUkJ9G8aEo8Hl5bbe5FHmpQEHLh1oxJot0CgufIGlev+vMH3cofBDVTGZ5BxqhlleqDZ2GYWiKcKV40NpyQ7CujOJ3uua6s0F5QUBueG999Ii7dXO/G1RH3rvRKldkgh37RvAzPEHTTV4h5LfEKpVTHGpGl912UVjp1KtPCZ5byrp1N/Rf41KG7ZUsaMjN1ke4amgbfnSuoSzIqsCfpqcYE1Ak9SUozD/KDK0KVzAow6VsSBTnQVxrQkFAZnYTxDovX3u7ZSzCUkLWfRVO5aughJqO3SqvBiOTkxcvwSoh5kESmrz6W3mwN3PLTZYzxHQlTxpj7K5A2BRH7t7UPczIZRyrbf+f5m7GH2mwzaxsVNIEJXDFNMUr7t8lgMYby6WXQcblixX/5NyJxCYbLp3CUWKGHjMnLSHcY+2jDKN8eYMmZRwwKJkMALzYxFvo5XjkU/DUtmRYXWoGITZHpcShc8ONHM3ovqZ5d+1ayr7IdfrJIB86bABowSw483kw8dQ2ujm1ethNl3R+mgCuNQmfPoBOCw71jKxWE9LpGHutgvdpHGDWf0i4+JuNYfegQ=----ATTACHMENT:----NzY1MDYwOTc0MzU3Mzk1MCAzMTA4NDM1NDczODA1NDAyIDM4MDU3MDA3ODU0MTg2MjI=