Skip to content
Snippets Groups Projects
Verified Commit 652b55e9 authored by Damien's avatar Damien
Browse files

FEAT #30 Priority Unit test + Move to src

parent 634bbd74
No related branches found
No related tags found
No related merge requests found
...@@ -5,8 +5,9 @@ ...@@ -5,8 +5,9 @@
"Basket\\" : "src/app/basket/", "Basket\\" : "src/app/basket/",
"Contact\\" : "src/app/contact/", "Contact\\" : "src/app/contact/",
"History\\" : "src/app/history/", "History\\" : "src/app/history/",
"Status\\" : "src/app/status/", "Priority\\" : "src/app/priority/",
"Resource\\" : "src/app/resource/", "Resource\\" : "src/app/resource/",
"Status\\" : "src/app/status/",
"Core\\" : "core/", "Core\\" : "core/",
"Apps\\" : "apps/maarch_entreprise/", "Apps\\" : "apps/maarch_entreprise/",
......
<?php <?php
namespace MaarchTest; /**
* Copyright Maarch since 2008 under licence GPLv3.
* See LICENCE.txt file at the root folder for more details.
* This file is part of Maarch software.
*
*/
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class PriorityControllerTest extends TestCase class PriorityControllerTest extends TestCase
...@@ -10,7 +16,7 @@ class PriorityControllerTest extends TestCase ...@@ -10,7 +16,7 @@ class PriorityControllerTest extends TestCase
public function testCreate() public function testCreate()
{ {
$priorityController = new \Core\Controllers\PriorityController(); $priorityController = new \Priority\controllers\PriorityController();
// CREATE // CREATE
$environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'POST']); $environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'POST']);
...@@ -46,7 +52,7 @@ class PriorityControllerTest extends TestCase ...@@ -46,7 +52,7 @@ class PriorityControllerTest extends TestCase
public function testGet() public function testGet()
{ {
$priorityController = new \Core\Controllers\PriorityController(); $priorityController = new \Priority\controllers\PriorityController();
// GET // GET
$environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'GET']); $environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'GET']);
...@@ -60,7 +66,7 @@ class PriorityControllerTest extends TestCase ...@@ -60,7 +66,7 @@ class PriorityControllerTest extends TestCase
public function testUpdate() public function testUpdate()
{ {
$priorityController = new \Core\Controllers\PriorityController(); $priorityController = new \Priority\controllers\PriorityController();
// UPDATE // UPDATE
$environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'PUT']); $environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'PUT']);
...@@ -77,7 +83,7 @@ class PriorityControllerTest extends TestCase ...@@ -77,7 +83,7 @@ class PriorityControllerTest extends TestCase
$response = $priorityController->update($fullRequest, new \Slim\Http\Response(), ['id' => self::$id]); $response = $priorityController->update($fullRequest, new \Slim\Http\Response(), ['id' => self::$id]);
$responseBody = json_decode((string)$response->getBody()); $responseBody = json_decode((string)$response->getBody());
$this->assertSame(_UPDATED_PRIORITY, $responseBody->success); $this->assertSame('success', $responseBody->success);
// READ // READ
$environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'GET']); $environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'GET']);
...@@ -94,7 +100,7 @@ class PriorityControllerTest extends TestCase ...@@ -94,7 +100,7 @@ class PriorityControllerTest extends TestCase
public function testDelete() public function testDelete()
{ {
$priorityController = new \Core\Controllers\PriorityController(); $priorityController = new \Priority\controllers\PriorityController();
// DELETE // DELETE
$environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'DELETE']); $environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'DELETE']);
...@@ -102,7 +108,7 @@ class PriorityControllerTest extends TestCase ...@@ -102,7 +108,7 @@ class PriorityControllerTest extends TestCase
$response = $priorityController->delete($request, new \Slim\Http\Response(), ['id' => self::$id]); $response = $priorityController->delete($request, new \Slim\Http\Response(), ['id' => self::$id]);
$responseBody = json_decode((string)$response->getBody()); $responseBody = json_decode((string)$response->getBody());
$this->assertSame(_DELETED_PRIORITY, $responseBody->success); $this->assertInternalType('array', $responseBody->priorities);
// READ // READ
$environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'GET']); $environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'GET']);
......
...@@ -215,11 +215,11 @@ $app->put('/parameters/{id}', \Core\Controllers\ParametersController::class . ': ...@@ -215,11 +215,11 @@ $app->put('/parameters/{id}', \Core\Controllers\ParametersController::class . ':
$app->delete('/parameters/{id}', \Core\Controllers\ParametersController::class . ':delete'); $app->delete('/parameters/{id}', \Core\Controllers\ParametersController::class . ':delete');
//Priorities //Priorities
$app->get('/priorities', \Core\Controllers\PriorityController::class . ':get'); $app->get('/priorities', \Priority\controllers\PriorityController::class . ':get');
$app->post('/priorities', \Core\Controllers\PriorityController::class . ':create'); $app->post('/priorities', \Priority\controllers\PriorityController::class . ':create');
$app->get('/priorities/{id}', \Core\Controllers\PriorityController::class . ':getById'); $app->get('/priorities/{id}', \Priority\controllers\PriorityController::class . ':getById');
$app->put('/priorities/{id}', \Core\Controllers\PriorityController::class . ':update'); $app->put('/priorities/{id}', \Priority\controllers\PriorityController::class . ':update');
$app->delete('/priorities/{id}', \Core\Controllers\PriorityController::class . ':delete'); $app->delete('/priorities/{id}', \Priority\controllers\PriorityController::class . ':delete');
//History //History
$app->get('/administration/history/eventDate/{date}', \History\controllers\HistoryController::class . ':getForAdministration'); $app->get('/administration/history/eventDate/{date}', \History\controllers\HistoryController::class . ':getForAdministration');
......
<?php <?php
namespace Core\Controllers; namespace Priority\controllers;
use Core\Models\ServiceModel; use Core\Models\ServiceModel;
use Priority\models\PriorityModel;
use Respect\Validation\Validator; use Respect\Validation\Validator;
use Core\Models\PriorityModel;
use Slim\Http\Request; use Slim\Http\Request;
use Slim\Http\Response; use Slim\Http\Response;
......
...@@ -10,12 +10,10 @@ ...@@ -10,12 +10,10 @@
/** /**
* @brief Priority Model * @brief Priority Model
* @author dev@maarch.org * @author dev@maarch.org
* @ingroup core
*/ */
namespace Core\Models; namespace Priority\models;
class PriorityModel extends PriorityModelAbstract class PriorityModel extends PriorityModelAbstract
{ {
// Do your stuff in this class
} }
\ No newline at end of file
...@@ -9,10 +9,12 @@ ...@@ -9,10 +9,12 @@
/** /**
* @brief Priority Abstract Model * @brief Priority Abstract Model
* @author dev@maarch.org * @author dev@maarch.org
* @ingroup core
*/ */
namespace Core\Models; namespace Priority\models;
use Core\Models\DatabaseModel;
use Core\Models\ValidatorModel;
abstract class PriorityModelAbstract abstract class PriorityModelAbstract
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment