Changeset 12064
- Timestamp:
- 10/08/08 08:13:45 (2 months ago)
- Files:
-
- branches/1.2/UPGRADE_TO_1_2 (modified) (1 diff)
- branches/1.2/lib/addon/sfData.class.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.2/UPGRADE_TO_1_2
r12063 r12064 666 666 The browser classes now add the `HTTP_REFERER` header for each request. 667 667 668 Tests669 ----- 668 Functional Tests 669 ---------------- 670 670 671 671 When you write a lot of functional tests for a given module, it is sometimes branches/1.2/lib/addon/sfData.class.php
r9083 r12064 50 50 * Loads data for the database from a YAML file 51 51 * 52 * @param string $fi xture_file The path to the YAML file.52 * @param string $file The path to the YAML file. 53 53 */ 54 protected function doLoadDataFromFile($fi xture_file)54 protected function doLoadDataFromFile($file) 55 55 { 56 56 // import new datas 57 $data = sfYaml::load($fi xture_file);57 $data = sfYaml::load($file); 58 58 59 59 $this->loadDataFromArray($data); … … 71 71 * loading them into the data source 72 72 * 73 * @param array $fi xture_files The path names of the YAML data files73 * @param array $files The path names of the YAML data files 74 74 */ 75 protected function doLoadData($fi xture_files)75 protected function doLoadData($files) 76 76 { 77 77 $this->object_references = array(); 78 78 $this->maps = array(); 79 79 80 sort($fixture_files); 81 foreach ($fixture_files as $fixture_file) 80 foreach ($files as $file) 82 81 { 83 $this->doLoadDataFromFile($fi xture_file);82 $this->doLoadDataFromFile($file); 84 83 } 85 84 } 86 85 87 86 /** 88 * Gets a list of one or more *.yml files and returns the list in an array 87 * Gets a list of one or more *.yml files and returns the list in an array. 89 88 * 90 * @param string $directory_or_file A directory or file name; if null, then defaults to 'sf_data_dir'/fixtures89 * The returned array of files is sorted by alphabetical order. 91 90 * 92 * @returns array A list of *.yml files. 91 * @param string|array $element A directory or file name or an array of directories and/or file names 92 * If null, then defaults to 'sf_data_dir'/fixtures 93 * 94 * @return array A list of *.yml files 93 95 * 94 96 * @throws sfInitializationException If the directory or file does not exist. 95 97 */ 96 p rotected function getFiles($directory_or_file= null)98 public function getFiles($element = null) 97 99 { 98 // directory or file? 99 $fixture_files = array(); 100 if (!$directory_or_file) 100 if (is_null($element)) 101 101 { 102 102 $directory_or_file = sfConfig::get('sf_data_dir').'/fixtures'; 103 103 } 104 104 105 if (is_file($directory_or_file)) 105 $files = array(); 106 if (is_array($element)) 106 107 { 107 $fixture_files[] = $directory_or_file; 108 foreach ($element as $e) 109 { 110 $files = array_merge($files, $this->getFiles($e)); 111 } 108 112 } 109 else if (is_ dir($directory_or_file))113 else if (is_file($element)) 110 114 { 111 $fixture_files = sfFinder::type('file')->name('*.yml')->in($directory_or_file); 115 $files[] = $element; 116 } 117 else if (is_dir($element)) 118 { 119 $files = sfFinder::type('file')->name('*.yml')->in($element); 112 120 } 113 121 else 114 122 { 115 throw new sfInitializationException('You must give a directory or a file.');123 throw new sfInitializationException('You must give an array, a directory or a file to sfPropelData::getFiles().'); 116 124 } 117 125 118 return $fixture_files; 126 $files = array_unique($files); 127 sort($files); 128 129 return $files; 119 130 } 120 131 }