Merge branch 're-write' of https://github.com/kiswa/TaskBoard into re-write

This commit is contained in:
Matthew Ross 2016-04-27 18:12:44 -04:00
commit 1a360f9a62
15 changed files with 276 additions and 28 deletions

View File

@ -7,7 +7,8 @@
</blacklist>
</filter>
<logging>
<log type="coverage-html" target="api-coverage/" />
<log type="coverage-html" target="api-coverage/"
lowUpperBound="30" highLowerBound="70" />
</logging>
</phpunit>

View File

@ -5,14 +5,3 @@ SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 year"
ExpiresByType text/x-javascript "access 9 months"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 seconds"
</IfModule>

View File

@ -5,7 +5,8 @@
"slim/slim": "^3.3",
"firebase/php-jwt": "^3.0",
"phpmailer/phpmailer": "^5.2",
"phpunit/phpunit": "^4.8"
"phpunit/phpunit": "^4.8",
"myclabs/php-enum": "^1.4"
},
"license": "MIT",
"authors": [

48
src/api/composer.lock generated
View File

@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "4d525f15d96360344612eef937df04f3",
"content-hash": "5eb7b7c370a74b3a8c4c8976ff018a64",
"hash": "bff093e16f6e6b1a99df84cf496efb96",
"content-hash": "a9c988ec77be5a9bd8f95671956cfaa1",
"packages": [
{
"name": "container-interop/container-interop",
@ -250,6 +250,50 @@
],
"time": "2016-04-12 18:29:35"
},
{
"name": "myclabs/php-enum",
"version": "1.4.1",
"source": {
"type": "git",
"url": "https://github.com/myclabs/php-enum.git",
"reference": "07da9d1a7469941ae05b046193fac4c83bdb0d7e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/myclabs/php-enum/zipball/07da9d1a7469941ae05b046193fac4c83bdb0d7e",
"reference": "07da9d1a7469941ae05b046193fac4c83bdb0d7e",
"shasum": ""
},
"require": {
"php": ">=5.3"
},
"require-dev": {
"phpunit/phpunit": "4.*",
"squizlabs/php_codesniffer": "1.*"
},
"type": "library",
"autoload": {
"psr-4": {
"MyCLabs\\Enum\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP Enum contributors",
"homepage": "https://github.com/myclabs/php-enum/graphs/contributors"
}
],
"description": "PHP Enum implementation",
"homepage": "http://github.com/myclabs/php-enum",
"keywords": [
"enum"
],
"time": "2015-07-22 16:14:03"
},
{
"name": "nikic/fast-route",
"version": "v0.6.0",

View File

@ -2,10 +2,10 @@
class Activity extends BaseModel {
public $id = 0;
public $user_id = '';
public $user_id = 0;
public $log_text ='';
public $before = '';
public $after = '';
public $before = null;
public $after = null;
public $item_type = '';
public $item_id = 0;

View File

@ -1,5 +1,10 @@
<?php
class Attachment extends BaseModel {
public $filename = '';
public $name = '';
public $type = '';
public $user_id = 0;
public $timestamp = null;
public function __construct($container, $id = 0) {
parent::__construct('attachment', $id, $container);
@ -15,6 +20,5 @@ class Attachment extends BaseModel {
public function loadFromJson($container, $obj) {
}
}

View File

@ -1,12 +1,48 @@
<?php
class AutoAction extends BaseModel {
use MyCLabs\Enum\Enum;
public function __construct($container, $id = 0) {
class ActionTrigger extends Enum {
const MoveToColumn = 1;
const AssignedToUser = 2;
const SetToCategory = 3;
}
class ActionType extends Enum {
const SetColor = 1;
const SetCategory = 2;
const SetAssignee = 3;
const ClearDueDate = 4;
}
class AutoAction extends BaseModel {
public $id = 0;
public $trigger = ActionTrigger::MoveToColumn;
public $trigger_id = 0; // ID of the column etc. which triggers the action
public $type = ActionType::SetColor;
// These are the target change to make when the action
// is performed. Only one will be set in an action.
// TODO: Consider other ways to do this.
public $color = '';
public $category_id = 0;
public $assignee_id = 0;
public function __construct($container, $id = 0, $internal = false) {
parent::__construct('auto_action', $id, $container);
if ($internal) {
return;
}
$this->loadFromBean($this->bean);
}
public static function fromJson($container, $json) {
$instance = new self($container, 0, true);
$instance->loadFromJson($container, $json);
return $instance;
}
public function updateBean() {
}
@ -15,6 +51,5 @@ class AutoAction extends BaseModel {
public function loadFromJson($container, $obj) {
}
}

View File

@ -0,0 +1,32 @@
<?php
class Category extends BaseModel {
public $id = 0;
public $title = '';
public function __construct($container, $id = 0, $internal = false) {
parent::__construct('column', $id, $container);
if ($internal) {
return;
}
$this->loadFromBean($this->bean);
}
public static function fromJson($container, $json) {
$instance = new self($container, 0, true);
$instance->loadFromJson($container, $json);
return $instance;
}
public function updateBean() {
}
public function loadFromBean($container, $bean) {
}
public function loadFromJson($container, $json) {
}
}

View File

@ -1,5 +1,9 @@
<?php
class Column extends BaseModel {
public $id = 0;
public $name = '';
public $position = 0;
public $tasks = []; // Task model array
public function __construct($container, $id = 0, $internal = false) {
parent::__construct('column', $id, $container);
@ -26,6 +30,5 @@ class Column extends BaseModel {
public function loadFromJson($container, $json) {
}
}

View File

@ -1,5 +1,7 @@
<?php
class Comment extends BaseModel {
public $id = 0;
public $text = '';
public function __construct($container, $id = 0) {
parent::__construct('comment', $id, $container);
@ -15,6 +17,5 @@ class Comment extends BaseModel {
public function loadFromJson($container, $obj) {
}
}

41
src/api/models/Task.php Normal file
View File

@ -0,0 +1,41 @@
<?php
class Task extends BaseModel {
public $id = 0;
public $title = '';
public $description = '';
public $assignee = null; // User model
public $category = null; // Category model
public $color = '';
public $due_date = null; // Date or null if not set
public $points = null; // Integer or null if not set
public $position = 0;
public $attachments = []; // Attachment model array
public $comments = []; // Comment model array
public function __construct($container, $id = 0, $internal = false) {
parent::__construct('column', $id, $container);
if ($internal) {
return;
}
$this->loadFromBean($this->bean);
}
public static function fromJson($container, $json) {
$instance = new self($container, 0, true);
$instance->loadFromJson($container, $json);
return $instance;
}
public function updateBean() {
}
public function loadFromBean($container, $bean) {
}
public function loadFromJson($container, $json) {
}
}

View File

@ -1,12 +1,39 @@
<?php
class User extends BaseModel {
use MyCLabs\Enum\Enum;
public function __construct($container, $id = 0) {
class SecurityLevel extends Enum {
const Admin = 1;
const BoardAdmin = 2;
const User = 3;
}
class User extends BaseModel {
public $id = 0;
public $security_level = SecurityLevel::User;
public $username = '';
public $salt = '';
public $password_hash = '';
public $email = '';
public $default_board_id = 0;
public $options = []; // UserOptions model
public function __construct($container, $id = 0, $internal = false) {
parent::__construct('user', $id, $container);
if ($internal) {
return;
}
$this->loadFromBean($this->bean);
}
public static function fromJson($container, $json) {
$instance = new self($container, 0, true);
$instance->loadFromJson($container, $json);
return $instance;
}
public function updateBean() {
}
@ -15,6 +42,5 @@ class User extends BaseModel {
public function loadFromJson($container, $obj) {
}
}

View File

@ -0,0 +1,22 @@
<?php
class UserOptions extends BaseModel {
public $task_order = 0;
public $show_animations = true;
public $show_assignee = true;
public function __construct($container, $id = 0) {
parent::__construct('user', $id, $container);
$this->loadFromBean($this->bean);
}
public function updateBean() {
}
public function loadFromBean($container, $bean) {
}
public function loadFromJson($container, $obj) {
}
}

View File

@ -2,7 +2,7 @@
require_once 'Mocks.php';
class BoardTest extends PHPUnit_Framework_TestCase {
private $json = '{ "id": 1, "name": "test", "is_active": true }';
private $json = '';
public static function setupBeforeClass() {
try {
@ -16,6 +16,54 @@ class BoardTest extends PHPUnit_Framework_TestCase {
}
}
protected function setUp() {
if ($this->json !== '') {
return;
}
$board = new stdClass();
$board->id = 1;
$board->name = 'test';
$board->is_active = true;
$board->columns = [];
$column = new stdClass();
$column->id = 1;
$column->name = 'col1';
$category = new stdClass();
$category->id = 1;
$category->name = 'cat1';
$auto_action = new stdClass();
$auto_action->id = 1;
$auto_action->trigger = ActionTrigger::MoveToColumn;
$auto_action->trigger_id = 1;
$auto_action->type = ActionType::SetColor;
$auto_action->color = '#ffffff';
$user = new stdClass();
$user->id = 1;
$user->security_level = 1;
$user->username = 'tester';
$board->columns[] = $column;
$board->categories[] = $category;
$board->auto_actions[] = $auto_action;
$board->users[] = $user;
$this->json = json_encode($board);
}
// Just to get the complete code coverage
public function testMockApp() {
$expected = new ContainerMock();
$appMock = new AppMock();
$actual = $appMock->getContainer();
$this->assertTrue($expected == $actual);
}
public function testCreateNewBoard() {
$board = new Board(new ContainerMock());

View File

@ -5,6 +5,7 @@ class AppMock {
public function getContainer() {
return new ContainerMock();
}
}
$app = new AppMock();