-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ability to disable form tabs closes #951
- Loading branch information
1 parent
850a4ea
commit 29c9954
Showing
7 changed files
with
121 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
namespace Mopa\Bundle\BootstrapBundle\Test\Form; | ||
|
||
use Symfony\Component\Form\Test\TypeTestCase; | ||
|
||
abstract class AbstractFormRenderTest extends TypeTestCase | ||
{ | ||
protected $twig; | ||
|
||
public function testForm() | ||
{ | ||
$fixture = sprintf('%s/Fixtures/%s', __DIR__, $this->getFixture()); | ||
|
||
if (!file_exists($fixture)) { | ||
$this->markTestSkipped(sprintf('Could not find fixture: %s', $fixture)); | ||
|
||
return; | ||
} | ||
|
||
$contents = file_get_contents($fixture); | ||
|
||
die($this->render($this->getForm())); | ||
} | ||
|
||
abstract public function getFixture(); | ||
abstract public function getForm(); | ||
|
||
public function render($form) | ||
{ | ||
return $this->getTwig()->render('{{ form(form) }}', array('form' => $form->createView())); | ||
} | ||
|
||
public function getTwig() | ||
{ | ||
if ($this->twig === null) { | ||
|
||
$fileLoader = new \Twig_Loader_Filesystem(array( | ||
__DIR__ . '/../../Resources/views', | ||
)); | ||
|
||
$loader = new \Twig_Loader_Chain(array( | ||
$fileLoader, | ||
new \Twig_Loader_String(), | ||
)); | ||
|
||
$this->twig = new \Twig_Environment($loader); | ||
$engine = new \Symfony\Bridge\Twig\Form\TwigRendererEngine(array( | ||
'Form/fields.html.twig', | ||
)); | ||
|
||
$renderer = new \Symfony\Bridge\Twig\Form\TwigRenderer($engine); | ||
|
||
$this->twig->addExtension(new \Symfony\Bridge\Twig\Extension\FormExtension($renderer)); | ||
$this->twig->addExtension(new \Mopa\Bundle\BootstrapBundle\Twig\IconExtension('glyphicons')); | ||
$this->twig->addExtension(new \Mopa\Bundle\BootstrapBundle\Twig\FormExtension()); | ||
$this->twig->addExtension(new \Symfony\Bridge\Twig\Extension\TranslationExtension($this->getMock('Symfony\Component\Translation\TranslatorInterface'))); | ||
} | ||
|
||
return $this->twig; | ||
} | ||
|
||
public function getExtensions() | ||
{ | ||
return array( | ||
new Extension\TestExtension(), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Mopa\Bundle\BootstrapBundle\Test\Form\Extension; | ||
|
||
use Mopa\Bundle\BootstrapBundle\Form\Extension\HorizontalFormTypeExtension; | ||
use Symfony\Component\Form\AbstractExtension; | ||
|
||
class TestExtension extends AbstractExtension | ||
{ | ||
public function loadTypeExtensions() | ||
{ | ||
return array( | ||
new HorizontalFormTypeExtension(array( | ||
'horizontal_label_class' => 'col-sm-3', | ||
'horizontal_label_offset_class' => 'col-sm-offset-3', | ||
'horizontal_input_wrapper_class' => 'col-sm-9', | ||
)), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="something"> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Mopa\Bundle\BootstrapBundle\Test\Form; | ||
|
||
class WidgetSimpleRenderTest extends AbstractFormRenderTest | ||
{ | ||
public function getFixture() | ||
{ | ||
return 'widget_simple.html'; | ||
} | ||
|
||
public function getForm() | ||
{ | ||
$form = $this->builder->create('form1', 'form', array( | ||
'horizontal' => true, | ||
)); | ||
|
||
$form | ||
->add('child1', 'text') | ||
; | ||
|
||
return $form->getForm(); | ||
} | ||
} |