-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More code coverage for Form components. Checks if children are accessible.
- Loading branch information
Mike Meier
committed
Apr 11, 2016
1 parent
14ab967
commit 3023dea
Showing
1 changed file
with
76 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sonata\AdminBundle\Tests\Util; | ||
|
||
use Sonata\AdminBundle\Util\FormBuilderIterator; | ||
use Symfony\Component\EventDispatcher\EventDispatcherInterface; | ||
use Symfony\Component\Form\FormBuilder; | ||
use Symfony\Component\Form\FormFactoryInterface; | ||
|
||
/** | ||
* @author Mike Meier <[email protected]> | ||
*/ | ||
class FormBuilderIteratorTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var EventDispatcherInterface | ||
*/ | ||
private $dispatcher; | ||
|
||
/** | ||
* @var FormFactoryInterface | ||
*/ | ||
private $factory; | ||
|
||
/** | ||
* @var FormBuilder | ||
*/ | ||
private $builder; | ||
|
||
protected function setUp() | ||
{ | ||
$this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); | ||
$this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); | ||
$this->builder = new TestFormBuilder('name', null, $this->dispatcher, $this->factory); | ||
$this->factory->expects($this->any())->method('createNamedBuilder')->willReturn($this->builder); | ||
} | ||
|
||
protected function tearDown() | ||
{ | ||
$this->dispatcher = null; | ||
$this->factory = null; | ||
$this->builder = null; | ||
} | ||
|
||
public function testConstructor() | ||
{ | ||
new FormBuilderIterator($this->builder); | ||
} | ||
|
||
public function testGetChildren() | ||
{ | ||
$this->builder->add('name', 'text'); | ||
$iterator = new FormBuilderIterator($this->builder); | ||
$this->assertInstanceOf(get_class($iterator), $iterator->getChildren()); | ||
} | ||
|
||
public function testHasChildren() | ||
{ | ||
$this->builder->add('name', 'text'); | ||
$iterator = new FormBuilderIterator($this->builder); | ||
$this->assertTrue($iterator->hasChildren()); | ||
} | ||
} | ||
|
||
class TestFormBuilder extends FormBuilder | ||
{ | ||
} |