Skip to content

Commit

Permalink
Fix test of the size of lines in MagicDb (included test for it).
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Story <mark@mark-story.com>
  • Loading branch information
jrbasso authored and markstory committed Nov 22, 2009
1 parent 7e889d8 commit c6c7474
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cake/libs/magic_db.php
Expand Up @@ -95,7 +95,7 @@ function toArray($data = null) {
$lines = explode("\r\n", $data);
$db = array();

$validHeader = count($lines > 3)
$validHeader = count($lines) > 3
&& preg_match('/^# Date:([0-9]{4}-[0-9]{2}-[0-9]{2})$/', $lines[1], $date)
&& preg_match('/^# Source:(.+)$/', $lines[2], $source)
&& strlen($lines[3]) == 0;
Expand Down
3 changes: 3 additions & 0 deletions cake/tests/cases/libs/magic_db.test.php
Expand Up @@ -116,6 +116,9 @@ function testToArray() {
$r = $this->Db->toArray(array('yeah'));
$this->assertTrue($r === array('yeah'));

$r = $this->Db->toArray("# FILE_ID DB\r\n# Date:2009-10-10\r\n# Source:xxx.php");
$this->assertTrue($r === array());

$r = $this->Db->toArray('foo');
$this->assertTrue($r === array());

Expand Down

0 comments on commit c6c7474

Please sign in to comment.