aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Controller/ControllerTest.php97
-rw-r--r--test/Model/QueryTest.php42
-rw-r--r--test/Model/ResultTest.php37
-rw-r--r--test/View/OutputTest.php33
4 files changed, 0 insertions, 209 deletions
diff --git a/test/Controller/ControllerTest.php b/test/Controller/ControllerTest.php
deleted file mode 100644
index 6931bc1..0000000
--- a/test/Controller/ControllerTest.php
+++ /dev/null
@@ -1,97 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace AugustOffensive\Controller;
-
-use PHPUnit\Framework\TestCase;
-use AugustOffensive\Model;
-
-/**
- * Integration test: requires DB connection. Expect side effects (use test db if possible).
- *
- * @covers Controller
- */
-final class ControllerTest extends \PHPUnit\Framework\TestCase
-{
- public function testDBConnection()
- {
- /* Disable integration test, for now
- try {
- $this->assertInstanceOf(
- Model\Connection::class,
- Controller::initiateConnection()
- );
- } catch (\PDOException $err) {
- $this->fail("Database not initialized correctly: " . $err->getMessage());
- }*/
- }
-
- public function testCreateQuery()
- {
- $path = array("api", "create", "query");
- $request = "DELETE";
- $content = array("c" => "cherry", "d" => "dike");
- $query = Controller::createQuery($path, $request, $content);
-
- $this->assertInstanceOf(
- Model\Query::class,
- $query
- );
-
- $this->assertEquals(
- $path,
- $query->getPath()
- );
- $this->assertEquals(
- $request,
- $query->getRequest()
- );
- $this->assertEquals(
- $content,
- $query->getContent()
- );
- }
-
- public function testCreateResult()
- {
-
- $resultType = "TYPE";
- $result = array("no", "values");
- $resultObject = Controller::createResult($resultType, $result);
-
- $this->assertInstanceOf(
- Model\Result::class,
- $resultObject
- );
-
- $this->assertEquals(
- $resultType,
- $resultObject->getResultType()
- );
- $this->assertEquals(
- $result,
- $resultObject->getResult()
- );
- }
-
- public function testErrorResult()
- {
- $message = "Oh no! Oops!";
- $errorResult = Controller::errorResult(new \Exception($message));
-
- $this->assertInstanceOf(
- Model\Result::class,
- $errorResult
- );
-
- $this->assertEquals(
- "ERROR",
- $errorResult->getResultType()
- );
- $this->assertEquals(
- array("error" => $message),
- $errorResult->getResult()
- );
- }
-}
diff --git a/test/Model/QueryTest.php b/test/Model/QueryTest.php
deleted file mode 100644
index ef6cda7..0000000
--- a/test/Model/QueryTest.php
+++ /dev/null
@@ -1,42 +0,0 @@
-<?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
deleted file mode 100644
index 0380182..0000000
--- a/test/Model/ResultTest.php
+++ /dev/null
@@ -1,37 +0,0 @@
-<?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()
- );
- }
-}
diff --git a/test/View/OutputTest.php b/test/View/OutputTest.php
deleted file mode 100644
index f687ee8..0000000
--- a/test/View/OutputTest.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?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