diff --git a/iqInternalTest.php b/iqInternalTest.php index b7ef8bb..3e8ca73 100644 --- a/iqInternalTest.php +++ b/iqInternalTest.php @@ -16,12 +16,16 @@ */ require __DIR__ . '/iq.drush.inc'; -function drush_log($m) { - echo $m . "\n\n"; -} +if (!function_exists('drush_log')) { + + function drush_log($m) { + echo $m . "\n\n"; + } + + function dt($t) { + return $t; + } -function dt($t) { - return $t; } class iqTestCase extends Drush_CommandTestCase { @@ -45,18 +49,30 @@ class iqTestCase extends Drush_CommandTestCase { $nid = "2125253"; $node = $this->downloadNode($nid); $author = $node->author; - $node->_drush_data["user/" . $author->id] = $this->downloadUser($author->id); + $this->addUser($node, $author->id); $comments = $node->comments; foreach ($comments as $comment) { // We could use $comment->uri if using Accept header and getting response $node->_drush_data["comment/" . $comment->id] = $this->downloadComment($comment->id); - $comment_author_id = $node->_drush_data["comment/" . $comment->id]->author->id; - $node->_drush_data["user/" . $comment_author_id] = $this->downloadUser($comment_author_id); + $this->addUser($node, $node->_drush_data["comment/" . $comment->id]->author->id); + } + + + foreach ($node->field_issue_files as $issue_file) { + // $issue_file is a compound object of display + file + $uri = 'file/' . $issue_file->file->id; + $node->_drush_data[$uri] = $this->fetchJson($uri); + $this->addUser($node, $node->_drush_data[$uri]->owner->id); } print_r($node); } + function addUser($item, $id) { + $uri = 'user/' . $id; + $item->_drush_data[$uri] = $this->fetchJson($uri); + } + function downloadNode($id) { return $this->fetchJson("node/$id"); } @@ -80,13 +96,18 @@ class iqTestCase extends Drush_CommandTestCase { } function cache_get($uri) { - @mkdir(__DIR__ . '/tests'); - @mkdir(__DIR__ . '/tests/data'); - @mkdir(__DIR__ . '/tests/data/download'); - @mkdir(__DIR__ . '/tests/data/download/node'); - @mkdir(__DIR__ . '/tests/data/download/comment'); - @mkdir(__DIR__ . '/tests/data/download/user'); - $file = __DIR__ . '/tests/data/download/' . $uri . '.json'; + $path = __DIR__ . '/tests'; + @mkdir($path); + @mkdir($path . '/data'); + @mkdir($path . '/data/download'); + @mkdir($path . '/data/download/node'); + @mkdir($path . '/data/download/comment'); + @mkdir($path . '/data/download/user'); + @mkdir($path . '/data/download/file'); + + $file = $path . '/data/download/' . $uri . '.json'; + // this fails on my system: why? + // mkdir(dirname($file), 0777, TRUE); if (file_exists($file)) { return file_get_contents($file); }