1
0
mirror of synced 2025-01-09 02:27:10 +03:00

Added support for field options to FieldBuilder

This commit is contained in:
Adam Pancutt 2013-10-15 12:36:47 +01:00
parent 95ad926c95
commit 25342b706d
2 changed files with 36 additions and 0 deletions

View File

@ -153,6 +153,35 @@ class FieldBuilder
return $this;
}
/**
* Sets an option.
*
* @param string $name
* @param mixed $value
*
* @return FieldBuilder
*/
public function option($name, $value)
{
if (!array_key_exists('options', $this->mapping)) {
$this->mapping['options'] = array();
}
$this->mapping['options'][$name] = $value;
return $this;
}
/**
* Sets unsigned option.
*
* @param bool $flag
*
* @return FieldBuilder
*/
public function unsigned($flag = true)
{
return $this->option('unsigned', (bool)$flag);
}
/**
* @param string $strategy
*

View File

@ -174,6 +174,13 @@ class ClassMetadataBuilderTest extends \Doctrine\Tests\OrmTestCase
$this->assertEquals(array('columnName' => 'id', 'fieldName' => 'id', 'id' => true, 'type' => 'integer'), $this->cm->fieldMappings['id']);
}
public function testCreateUnsignedOptionField()
{
$this->builder->createField('state', 'integer')->unsigned()->build();
$this->assertEquals(array('fieldName' => 'state', 'type' => 'integer', 'options' => array('unsigned' => true), 'columnName' => 'state'), $this->cm->fieldMappings['state']);
}
public function testAddLifecycleEvent()
{
$this->builder->addLifecycleEvent('getStatus', 'postLoad');