mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Fixed bug in MagicDbTestData class
Added support for serialized sample arrays Finished MagicDb parsing implementation Began to implement analyzing Updated tests git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5732 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
366cb23a64
commit
8963c16c77
2 changed files with 51 additions and 8 deletions
|
@ -40,6 +40,13 @@ class MagicDb extends Object {
|
||||||
**/
|
**/
|
||||||
var $db = array();
|
var $db = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The file currently being read. Can be a string or a file resource
|
||||||
|
*
|
||||||
|
* @var mixed
|
||||||
|
*/
|
||||||
|
var $_file = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a MagicDb from various formats
|
* Reads a MagicDb from various formats
|
||||||
*
|
*
|
||||||
|
@ -85,7 +92,7 @@ class MagicDb extends Object {
|
||||||
if (is_array($data)) {
|
if (is_array($data)) {
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
if (empty($data)) {
|
if ($data === null) {
|
||||||
return $this->db;
|
return $this->db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,11 +124,13 @@ class MagicDb extends Object {
|
||||||
$columns = explode("\t", $line);
|
$columns = explode("\t", $line);
|
||||||
if (in_array($columns[0]{0}, array('&', '>'))) {
|
if (in_array($columns[0]{0}, array('&', '>'))) {
|
||||||
$format[] = $columns;
|
$format[] = $columns;
|
||||||
} else {
|
} elseif (!empty($format)) {
|
||||||
$db['database'][] = $format;
|
$db['database'][] = $format;
|
||||||
$format = array();
|
$format = array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $db;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -150,6 +159,16 @@ class MagicDb extends Object {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function analyze($file, $options = array()) {
|
function analyze($file, $options = array()) {
|
||||||
|
if (!is_string($file)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file_exists($file)) {
|
||||||
|
$this->_file =& new File($file);
|
||||||
|
} else {
|
||||||
|
$this->_file = $file;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue