1
0
mirror of synced 2025-01-29 19:41:45 +03:00

refactoring tests

This commit is contained in:
Fabio B. Silva 2012-11-27 14:38:18 -02:00
parent 41b907606f
commit d1dc72b65a
2 changed files with 23 additions and 29 deletions

View File

@ -139,7 +139,7 @@ class EntityGenerator
/**
* Hash-map for handle types
*
*
* @var array
*/
protected $typeAlias = array(
@ -158,7 +158,7 @@ class EntityGenerator
);
/**
* @var array Hash-map to handle generator types string
* @var array Hash-map to handle generator types string.
*/
protected static $generatorStrategyMap = array(
ClassMetadataInfo::GENERATOR_TYPE_AUTO => 'AUTO',

View File

@ -349,53 +349,49 @@ class EntityGeneratorTest extends \Doctrine\Tests\OrmTestCase
$method = new \ReflectionMethod($this->_generator, 'getInheritanceTypeString');
$constants = $reflection->getConstants();
$pattern = '/^INHERITANCE_TYPE_/';
$map = array();
$method->setAccessible(true);
foreach ($constants as $name => $value) {
if(preg_match($pattern, $name)) {
$map[preg_replace($pattern, '', $name)] = $value;
if( ! preg_match($pattern, $name)) {
continue;
}
}
foreach ($map as $expected => $type) {
$actual = $method->invoke($this->_generator, $type);
$expected = preg_replace($pattern, '', $name);
$actual = $method->invoke($this->_generator, $value);
$this->assertEquals($expected, $actual);
}
$this->setExpectedException('\InvalidArgumentException', 'Invalid provided InheritanceType: INVALID');
$method->invoke($this->_generator, 'INVALID');
$this->setExpectedException('\InvalidArgumentException', 'Invalid provided InheritanceType: INVALID');
$method->invoke($this->_generator, 'INVALID');
}
/**
* @group DDC-2172
*/
/**
* @group DDC-2172
*/
public function testGetChangeTrackingPolicyString()
{
$reflection = new \ReflectionClass('\Doctrine\ORM\Mapping\ClassMetadata');
$method = new \ReflectionMethod($this->_generator, 'getChangeTrackingPolicyString');
$constants = $reflection->getConstants();
$pattern = '/^CHANGETRACKING_/';
$map = array();
$method->setAccessible(true);
foreach ($constants as $name => $value) {
if(preg_match($pattern, $name)) {
$map[preg_replace($pattern, '', $name)] = $value;
if( ! preg_match($pattern, $name)) {
continue;
}
}
foreach ($map as $expected => $type) {
$actual = $method->invoke($this->_generator, $type);
$expected = preg_replace($pattern, '', $name);
$actual = $method->invoke($this->_generator, $value);
$this->assertEquals($expected, $actual);
}
$this->setExpectedException('\InvalidArgumentException', 'Invalid provided ChangeTrackingPolicy: INVALID');
$method->invoke($this->_generator, 'INVALID');
$this->setExpectedException('\InvalidArgumentException', 'Invalid provided ChangeTrackingPolicy: INVALID');
$method->invoke($this->_generator, 'INVALID');
}
/**
@ -407,24 +403,22 @@ class EntityGeneratorTest extends \Doctrine\Tests\OrmTestCase
$method = new \ReflectionMethod($this->_generator, 'getIdGeneratorTypeString');
$constants = $reflection->getConstants();
$pattern = '/^GENERATOR_TYPE_/';
$map = array();
$method->setAccessible(true);
foreach ($constants as $name => $value) {
if(preg_match($pattern, $name)) {
$map[preg_replace($pattern, '', $name)] = $value;
if( ! preg_match($pattern, $name)) {
continue;
}
}
foreach ($map as $expected => $type) {
$actual = $method->invoke($this->_generator, $type);
$expected = preg_replace($pattern, '', $name);
$actual = $method->invoke($this->_generator, $value);
$this->assertEquals($expected, $actual);
}
$this->setExpectedException('\InvalidArgumentException', 'Invalid provided IdGeneratorType: INVALID');
$method->invoke($this->_generator, 'INVALID');
$this->setExpectedException('\InvalidArgumentException', 'Invalid provided IdGeneratorType: INVALID');
$method->invoke($this->_generator, 'INVALID');
}
/**