Blame view

framework/dev/BehatFixtureFactory.php 680 Bytes
0084d336   Administrator   Importers CRUD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  <?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.
  		if(!$name != 'File' && !is_subclass_of($name, 'File')) {
  			foreach(array('Name', 'Title') as $fieldName) {
  				if(singleton($name)->hasField($fieldName) && !isset($data[$fieldName])) {
  					$data[$fieldName] = $identifier;
  					break;
  				}
  			}	
  		}
  
  		return parent::createObject($name, $identifier, $data);
  	}
  }