[Form] changed the way default type names are created to avoid collisions
This commit is contained in:
parent
f3cafcb355
commit
d044498cde
@ -128,15 +128,13 @@ abstract class AbstractType implements FormTypeInterface
|
||||
/**
|
||||
* Returns the name of this type.
|
||||
*
|
||||
* The default name type is the class name without the Form nor Type suffix
|
||||
* The default name type is the class name, where \ are replaced by _.
|
||||
*
|
||||
* @return string The name of this type
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
preg_match('/\\\\(\w+?)(Form)?(Type)?$/i', get_class($this), $matches);
|
||||
|
||||
return strtolower($matches[1]);
|
||||
return strtolower(str_replace('\\', '_', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,28 +19,28 @@ class AbstractTypeTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$type = new MyTest();
|
||||
|
||||
$this->assertEquals('mytest', $type->getName());
|
||||
$this->assertEquals('symfony_tests_component_form_mytest', $type->getName());
|
||||
}
|
||||
|
||||
public function testGetNameWithTypeSuffix()
|
||||
{
|
||||
$type = new MyTestType();
|
||||
|
||||
$this->assertEquals('mytest', $type->getName());
|
||||
$this->assertEquals('symfony_tests_component_form_mytesttype', $type->getName());
|
||||
}
|
||||
|
||||
public function testGetNameWithFormSuffix()
|
||||
{
|
||||
$type = new MyTestForm();
|
||||
|
||||
$this->assertEquals('mytest', $type->getName());
|
||||
$this->assertEquals('symfony_tests_component_form_mytestform', $type->getName());
|
||||
}
|
||||
|
||||
public function testGetNameWithFormTypeSuffix()
|
||||
{
|
||||
$type = new MyTestFormType();
|
||||
|
||||
$this->assertEquals('mytest', $type->getName());
|
||||
$this->assertEquals('symfony_tests_component_form_mytestformtype', $type->getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user