Ejemplo n.º 1
0
 /** @test */
 public function it_should_use_all_the_blocks_defined_in_the_current_template()
 {
     $price = new Text('price');
     $captcha = new Captcha('captcha', new FakeCaptchaAdapter());
     $html = $this->environment->render('forms/captcha.html.twig', ['price' => $price->buildView(), 'captcha' => $captchaView = $captcha->buildView()]);
     $this->assertEquals(sprintf('<div class="form-group"><label for="price">Price</label><div class="input-group"><div class="input-group-addon">$</div><input type="text" name="price" id="price" class="form-control"><div class="input-group-addon">.00</div></div></div><div class="form-group"><label>Please type this word below</label><img alt="" src="/images/capctha/%s.png"><br><input name="captcha[input]" type="text"><input name="captcha[id]" type="hidden" value="%s"></div>', $captchaView->options['captcha_id'], $captchaView->options['captcha_id']), $html);
 }
Ejemplo n.º 2
0
 function it_should_render_an_element_with_options(FormTheme $theme, Template $template)
 {
     $captcha = new Captcha('captcha', new FakeCaptchaAdapter());
     $captcha->setValue('1325');
     $htmlAttributes = ['class' => 'js-highlighted'];
     $captchaOptions = ['image_attr' => ['id' => 'js-captcha']];
     $captchaView = $captcha->buildView();
     $theme->loadTemplateFor($captchaView->block)->willReturn($template);
     $theme->blocks()->willReturn([]);
     $this->renderElement($captchaView, $htmlAttributes, $captchaOptions);
     $template->displayBlock($captchaView->block, ['element' => $captchaView, 'attr' => $captchaView->attributes + $htmlAttributes, 'value' => $captchaView->value, 'options' => $captchaView->options + $captchaOptions, 'choices' => []], [])->shouldHaveBeenCalled();
 }