Skip to content

Commit

Permalink
split testing setDefaultOptions and configureOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
adam187 committed Jun 4, 2015
1 parent c217913 commit 0177d6f
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions Tests/Form/Type/ImageTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,44 @@ public function testGetParent()
$this->assertEquals('file', $type->getParent());
}

public function testSetDefaultOptions()
public function testConfigureOptions()
{
if (version_compare(Kernel::VERSION_ID, '20600') < 0) {
$this->markTestSkipped('No need to test on symfony < 2.6');
}

$resolver = new OptionsResolver();
$type = new ImageType();

$type->configureOptions($resolver);

$this->assertTrue($resolver->isRequired('image_path'));
$this->assertTrue($resolver->isRequired('image_filter'));

$this->assertTrue($resolver->isDefined('image_attr'));
$this->assertTrue($resolver->isDefined('link_url'));
$this->assertTrue($resolver->isDefined('link_filter'));
$this->assertTrue($resolver->isDefined('link_attr'));
}

public function testLegacySetDefaultOptions()
{
if (version_compare(Kernel::VERSION_ID, '20600') >= 0) {
$setOptionsMethod = 'configureOptions';
$isDefinedMethod = 'isDefined';
} else {
$setOptionsMethod = 'setDefaultOptions';
$isDefinedMethod = 'isKnown';
$this->markTestSkipped('No need to test on symfony >= 2.6');
}

$type->$setOptionsMethod($resolver);
$resolver = new OptionsResolver();
$type = new ImageType();

$type->setDefaultOptions($resolver);

$this->assertTrue($resolver->isRequired('image_path'));
$this->assertTrue($resolver->isRequired('image_filter'));

$this->assertTrue($resolver->$isDefinedMethod('image_attr'));
$this->assertTrue($resolver->$isDefinedMethod('link_url'));
$this->assertTrue($resolver->$isDefinedMethod('link_filter'));
$this->assertTrue($resolver->$isDefinedMethod('link_attr'));
$this->assertTrue($resolver->isKnown('image_attr'));
$this->assertTrue($resolver->isKnown('link_url'));
$this->assertTrue($resolver->isKnown('link_filter'));
$this->assertTrue($resolver->isKnown('link_attr'));
}

public function testBuildView()
Expand Down

0 comments on commit 0177d6f

Please sign in to comment.