Skip to content

Commit

Permalink
Added named keys to the parsed responses
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjo-blur committed Dec 4, 2013
1 parent 5830691 commit 1654f00
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Quahog/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,13 @@ private function _parseResponse($response)
$message = $splitResponse[1];

if ($message === 'OK') {
return array($filename, '', 'OK');
return array('filename' => $filename, 'reason' => null, 'status' => 'OK');
} else {
$parts = explode(' ', $message);
$status = array_pop($parts);
$reason = implode(' ', $parts);

return array($filename, $reason, $status);
return array('filename' => $filename, 'reason' => $reason, 'status' => $status);
}
}
}
10 changes: 5 additions & 5 deletions tests/QuahogTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,22 @@ public function testScanFile()
{
$result = $this->quahog->scanFile('/tmp/quahog/EICAR');

$this->assertSame(array('/tmp/quahog/EICAR', 'Eicar-Test-Signature', 'FOUND'), $result);
$this->assertSame(array('filename' => '/tmp/quahog/EICAR', 'reason' => 'Eicar-Test-Signature', 'status' => 'FOUND'), $result);
}

public function testMultiscanFile()
{
$result = $this->quahog->multiscanFile('/tmp/quahog');

$this->assertSame('Eicar-Test-Signature', $result[1]);
$this->assertSame('FOUND', $result[2]);
$this->assertSame('Eicar-Test-Signature', $result['reason']);
$this->assertSame('FOUND', $result['status']);
}

public function testContScan()
{
$result = $this->quahog->contScan('/tmp/quahog');

$this->assertSame(array('/tmp/quahog/EICAR', 'Eicar-Test-Signature', 'FOUND'), $result);
$this->assertSame(array('filename' => '/tmp/quahog/EICAR', 'reason' => 'Eicar-Test-Signature', 'status' => 'FOUND'), $result);
}

public function testScanStream()
Expand All @@ -112,7 +112,7 @@ public function testScanStream()

$result = $this->quahog->scanStream($stream);

$this->assertSame(array('stream', 'Eicar-Test-Signature', 'FOUND'), $result);
$this->assertSame(array('filename' => 'stream', 'reason' => 'Eicar-Test-Signature', 'status' => 'FOUND'), $result);
}

public function testShutdown()
Expand Down

0 comments on commit 1654f00

Please sign in to comment.