diff --git a/PhpUnit.xml b/PhpUnit.xml index 47e7b02..ca6b403 100644 --- a/PhpUnit.xml +++ b/PhpUnit.xml @@ -7,7 +7,8 @@ - + diff --git a/src/.htaccess b/src/.htaccess index 298b0d3..0aeead9 100644 --- a/src/.htaccess +++ b/src/.htaccess @@ -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 - -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" - diff --git a/src/api/composer.json b/src/api/composer.json index c2490a3..39ee7f1 100644 --- a/src/api/composer.json +++ b/src/api/composer.json @@ -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": [ diff --git a/src/api/composer.lock b/src/api/composer.lock index 2083ea1..01d69e9 100644 --- a/src/api/composer.lock +++ b/src/api/composer.lock @@ -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", diff --git a/src/api/models/Activity.php b/src/api/models/Activity.php index 9302e61..0b6622a 100644 --- a/src/api/models/Activity.php +++ b/src/api/models/Activity.php @@ -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; diff --git a/src/api/models/Attachment.php b/src/api/models/Attachment.php index cef987b..51fe775 100644 --- a/src/api/models/Attachment.php +++ b/src/api/models/Attachment.php @@ -1,5 +1,10 @@ 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) { } - } diff --git a/src/api/models/Category.php b/src/api/models/Category.php new file mode 100644 index 0000000..8c2142e --- /dev/null +++ b/src/api/models/Category.php @@ -0,0 +1,32 @@ +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) { + } +} + diff --git a/src/api/models/Column.php b/src/api/models/Column.php index 6c612da..cfa53bb 100644 --- a/src/api/models/Column.php +++ b/src/api/models/Column.php @@ -1,5 +1,9 @@ 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) { + } +} + diff --git a/src/api/models/User.php b/src/api/models/User.php index fd2a723..d683c1c 100644 --- a/src/api/models/User.php +++ b/src/api/models/User.php @@ -1,12 +1,39 @@ 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) { } - } diff --git a/src/api/models/UserOptions.php b/src/api/models/UserOptions.php new file mode 100644 index 0000000..3493683 --- /dev/null +++ b/src/api/models/UserOptions.php @@ -0,0 +1,22 @@ +loadFromBean($this->bean); + } + + public function updateBean() { + } + + public function loadFromBean($container, $bean) { + } + + public function loadFromJson($container, $obj) { + } +} + diff --git a/test/api/BoardTest.php b/test/api/BoardTest.php index 409817e..b7c1af0 100644 --- a/test/api/BoardTest.php +++ b/test/api/BoardTest.php @@ -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()); diff --git a/test/api/Mocks.php b/test/api/Mocks.php index 36c388b..7743888 100644 --- a/test/api/Mocks.php +++ b/test/api/Mocks.php @@ -5,6 +5,7 @@ class AppMock { public function getContainer() { return new ContainerMock(); } + } $app = new AppMock();