2013-06-05 11:40:36 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @package framework
|
|
|
|
* @subpackage testing
|
|
|
|
*/
|
|
|
|
class BehatFixtureFactory extends \FixtureFactory {
|
|
|
|
public function createObject($name, $identifier, $data = null) {
|
|
|
|
if(!$data) $data = array();
|
|
|
|
|
|
|
|
// Copy identifier to some visible property unless its already defined.
|
|
|
|
// Exclude files, since they generate their own named based on the file path.
|
2013-07-11 15:13:27 +02:00
|
|
|
if(!$name != 'File' && !is_subclass_of($name, 'File')) {
|
2013-06-05 11:40:36 +02:00
|
|
|
foreach(array('Name', 'Title') as $fieldName) {
|
|
|
|
if(singleton($name)->hasField($fieldName) && !isset($data[$fieldName])) {
|
|
|
|
$data[$fieldName] = $identifier;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::createObject($name, $identifier, $data);
|
|
|
|
}
|
|
|
|
}
|