aboutsummaryrefslogtreecommitdiff
path: root/test/View/OutputTest.php
diff options
context:
space:
mode:
authorKevin Hoerr <kjhoerr@protonmail.com>2017-09-13 00:50:17 -0400
committerGitHub <noreply@github.com>2017-09-13 00:50:17 -0400
commit70ef99429394e142905a3058efc4c83a42517b67 (patch)
tree585996beb1a7f4b6c1fd4cd7e24619dff146b816 /test/View/OutputTest.php
parentcf5f5aee4831bb8476f2d593276b6ef17c3edc58 (diff)
downloadaugust-offensive-70ef99429394e142905a3058efc4c83a42517b67.tar.gz
august-offensive-70ef99429394e142905a3058efc4c83a42517b67.tar.bz2
august-offensive-70ef99429394e142905a3058efc4c83a42517b67.zip
2 - Tests (#3)
* Move autoload to separate script, add two unit tests * Add integration tests for Controller * Add unit test for Output * Fix Model\Result-as-a-method error * encode JSON output as utf-8, and retrieve as assoc array * Ignore utf-8 definitions
Diffstat (limited to 'test/View/OutputTest.php')
-rw-r--r--test/View/OutputTest.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/View/OutputTest.php b/test/View/OutputTest.php
new file mode 100644
index 0000000..f687ee8
--- /dev/null
+++ b/test/View/OutputTest.php
@@ -0,0 +1,33 @@
+<?php
+
+declare(strict_types=1);
+
+namespace AugustOffensive\View;
+
+use PHPUnit\Framework\TestCase;
+use AugustOffensive\Model;
+
+/**
+ * @covers Output
+ */
+final class OutputTest extends \PHPUnit\Framework\TestCase
+{
+ public function testJSONOutput()
+ {
+ $resultType = "JSON_ENCODED";
+ $result = array("json", "1.6");
+ $resultObject = new Model\Result($resultType, $result);
+
+ // If JSON is properly formatted, we can decode and test the values
+ $output = json_decode(Output::json($resultObject), true);
+
+ $this->assertEquals(
+ $resultType,
+ $output["Result-Type"]
+ );
+ $this->assertEquals(
+ $result,
+ $output["Content"]
+ );
+ }
+} \ No newline at end of file