Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
195 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace Craue\FormFlowBundle\Tests\IntegrationTestBundle\Entity; | ||
|
||
/** | ||
* @author Christian Raue <christian.raue@gmail.com> | ||
* @copyright 2011-2014 Christian Raue | ||
* @license http://opensource.org/licenses/mit-license.php MIT License | ||
*/ | ||
class Issue149Data { | ||
|
||
/** | ||
* @var Issue149SubData | ||
*/ | ||
public $photo; | ||
|
||
} |
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 Craue\FormFlowBundle\Tests\IntegrationTestBundle\Entity; | ||
|
||
use Symfony\Component\HttpFoundation\File\UploadedFile; | ||
|
||
/** | ||
* @author Christian Raue <christian.raue@gmail.com> | ||
* @copyright 2011-2014 Christian Raue | ||
* @license http://opensource.org/licenses/mit-license.php MIT License | ||
*/ | ||
class Issue149SubData { | ||
|
||
/** | ||
* @var UploadedFile | ||
*/ | ||
public $image; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public $title; | ||
|
||
} |
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,52 @@ | ||
<?php | ||
|
||
namespace Craue\FormFlowBundle\Tests\IntegrationTestBundle\Form; | ||
|
||
use Craue\FormFlowBundle\Form\FormFlow; | ||
|
||
/** | ||
* @author Christian Raue <christian.raue@gmail.com> | ||
* @copyright 2011-2014 Christian Raue | ||
* @license http://opensource.org/licenses/mit-license.php MIT License | ||
*/ | ||
class Issue149Flow extends FormFlow { | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getName() { | ||
return 'issue149'; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
protected function loadStepsConfig() { | ||
return array( | ||
array( | ||
'label' => 'step1', | ||
'type' => 'issue149', | ||
), | ||
array( | ||
'label' => 'step2', | ||
'type' => 'issue149', | ||
), | ||
array( | ||
'label' => 'step3', | ||
'type' => 'issue149', | ||
), | ||
); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getFormOptions($step, array $options = array()) { | ||
$options = parent::getFormOptions($step, $options); | ||
|
||
$options['cascade_validation'] = true; | ||
|
||
return $options; | ||
} | ||
|
||
} |
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,39 @@ | ||
<?php | ||
|
||
namespace Craue\FormFlowBundle\Tests\IntegrationTestBundle\Form; | ||
|
||
use Craue\FormFlowBundle\Tests\IntegrationTestBundle\Entity\Issue149SubData; | ||
use Symfony\Component\Form\AbstractType; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
|
||
/** | ||
* @author Christian Raue <christian.raue@gmail.com> | ||
* @copyright 2011-2014 Christian Raue | ||
* @license http://opensource.org/licenses/mit-license.php MIT License | ||
*/ | ||
class Issue149Form extends AbstractType { | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function buildForm(FormBuilderInterface $builder, array $options) { | ||
switch ($options['flow_step']) { | ||
case 1: | ||
$subForm = $builder->create('photo', 'form', array( | ||
'data_class' => get_class(new Issue149SubData()), | ||
)); | ||
$subForm->add('image', 'file'); | ||
$subForm->add('title'); | ||
$builder->add($subForm); | ||
break; | ||
} | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getName() { | ||
return 'issue149'; | ||
} | ||
|
||
} |
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
1 change: 1 addition & 0 deletions
1
Tests/IntegrationTestBundle/Resources/views/FormFlow/issue149.html.twig
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 @@ | ||
{% extends 'IntegrationTestBundle::layout_flow.html.twig' %} |
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,42 @@ | ||
<?php | ||
|
||
namespace Craue\FormFlowBundle\Tests; | ||
|
||
use Craue\FormFlowBundle\Tests\IntegrationTestCase; | ||
|
||
/** | ||
* @group integration | ||
* @see https://github.com/craue/CraueFormFlowBundle/issues/149 | ||
* | ||
* @author Christian Raue <christian.raue@gmail.com> | ||
* @copyright 2011-2014 Christian Raue | ||
* @license http://opensource.org/licenses/mit-license.php MIT License | ||
*/ | ||
class Issue149Test extends IntegrationTestCase { | ||
|
||
/** | ||
* The issue is caused by existence of a file field, regardless of actually uploading a file. | ||
*/ | ||
public function testIssue149() { | ||
$crawler = $this->client->request('GET', $this->url('_FormFlow_issue149')); | ||
$this->assertSame(200, $this->client->getResponse()->getStatusCode()); | ||
$this->assertCurrentStepNumber(1, $crawler); | ||
$this->assertCurrentFormData('{"photo":null}', $crawler); | ||
|
||
// enter a title -> step 2 | ||
$form = $crawler->selectButton('next')->form(); | ||
$crawler = $this->client->submit($form, array( | ||
'issue149[photo][title]' => 'blue pixel', | ||
)); | ||
$this->assertCurrentStepNumber(2, $crawler); | ||
$this->assertCurrentFormData('{"photo":{"image":null,"title":"blue pixel"}}', $crawler); | ||
|
||
// next -> step 3 | ||
$form = $crawler->selectButton('next')->form(); | ||
$crawler = $this->client->submit($form); | ||
$this->assertCurrentStepNumber(3, $crawler); | ||
// ensure that the title is preserved | ||
$this->assertCurrentFormData('{"photo":{"image":null,"title":"blue pixel"}}', $crawler); | ||
} | ||
|
||
} |