Permalink
Browse files

Fix test of the size of lines in MagicDb (included test for it).

Signed-off-by: Mark Story <mark@mark-story.com>
  • Loading branch information...
1 parent 7e889d8 commit c6c747450252c01cc18495c083df16cd1dea353c @jrbasso jrbasso committed with markstory Nov 20, 2009
Showing with 4 additions and 1 deletion.
  1. +1 −1 cake/libs/magic_db.php
  2. +3 −0 cake/tests/cases/libs/magic_db.test.php
View
@@ -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;
@@ -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());

0 comments on commit c6c7474

Please sign in to comment.