aboutsummaryrefslogtreecommitdiff
path: root/test/Model
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/Model
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/Model')
-rw-r--r--test/Model/QueryTest.php42
-rw-r--r--test/Model/ResultTest.php37
2 files changed, 79 insertions, 0 deletions
diff --git a/test/Model/QueryTest.php b/test/Model/QueryTest.php
new file mode 100644
index 0000000..ef6cda7
--- /dev/null
+++ b/test/Model/QueryTest.php
@@ -0,0 +1,42 @@
+<?php
+
+declare(strict_types=1);
+
+namespace AugustOffensive\Model;
+
+use PHPUnit\Framework\TestCase;
+
+/**
+ * @covers Query
+ */
+final class QueryTest extends \PHPUnit\Framework\TestCase
+{
+ public function testCanBeCreated()
+ {
+ $this->assertInstanceOf(
+ Query::class,
+ new Query(array("api", "path"), "GET", array())
+ );
+ }
+
+ public function testHasAccessibleValues()
+ {
+ $path = array("api", "query", "path");
+ $request = "PUT";
+ $content = array("a" => "apple", "b" => "bearing");
+ $query = new Query($path, $request, $content);
+
+ $this->assertEquals(
+ $path,
+ $query->getPath()
+ );
+ $this->assertEquals(
+ $request,
+ $query->getRequest()
+ );
+ $this->assertEquals(
+ $content,
+ $query->getContent()
+ );
+ }
+}
diff --git a/test/Model/ResultTest.php b/test/Model/ResultTest.php
new file mode 100644
index 0000000..0380182
--- /dev/null
+++ b/test/Model/ResultTest.php
@@ -0,0 +1,37 @@
+<?php
+
+declare(strict_types=1);
+
+namespace AugustOffensive\Model;
+
+use PHPUnit\Framework\TestCase;
+
+/**
+ * @covers Result
+ */
+final class ResultTest extends \PHPUnit\Framework\TestCase
+{
+ public function testCanBeCreated()
+ {
+ $this->assertInstanceOf(
+ Result::class,
+ new Result("TEST_SUCCESS", array("it worked"))
+ );
+ }
+
+ public function testHasAccessibleValues()
+ {
+ $resultType = "VISIBLE";
+ $result = array("array", "of", "values");
+ $resultObject = new Result($resultType, $result);
+
+ $this->assertEquals(
+ $resultType,
+ $resultObject->getResultType()
+ );
+ $this->assertEquals(
+ $result,
+ $resultObject->getResult()
+ );
+ }
+}