refactor: clean up code and remove some dependencies
This commit is contained in:
parent
2d2122e05d
commit
98b67855ca
@ -14,9 +14,6 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.5",
|
"php": ">=5.5",
|
||||||
"sabre/dav": "~3.1.2",
|
"sabre/dav": "~3.1.2",
|
||||||
"jms/serializer": "2.0.0-RC1",
|
|
||||||
"jms/metadata": "^2.0@RC",
|
|
||||||
"aerex/taskwarrior": "^3.0",
|
|
||||||
"sabre/vobject": "^4.0",
|
"sabre/vobject": "^4.0",
|
||||||
"easycorp/easy-log-handler": "^1.0"
|
"easycorp/easy-log-handler": "^1.0"
|
||||||
},
|
},
|
||||||
|
273
composer.lock
generated
273
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "2dbe239080807aae57bee30b874cf94c",
|
"content-hash": "227e2d4091133d951637324bc455c602",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "aerex/taskwarrior",
|
"name": "aerex/taskwarrior",
|
||||||
@ -58,6 +58,37 @@
|
|||||||
],
|
],
|
||||||
"time": "2018-10-28T17:53:34+00:00"
|
"time": "2018-10-28T17:53:34+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "container-interop/container-interop",
|
||||||
|
"version": "1.2.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/container-interop/container-interop.git",
|
||||||
|
"reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/container-interop/container-interop/zipball/79cbf1341c22ec75643d841642dd5d6acd83bdb8",
|
||||||
|
"reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"psr/container": "^1.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Interop\\Container\\": "src/Interop/Container/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"description": "Promoting the interoperability of container objects (DIC, SL, etc.)",
|
||||||
|
"homepage": "https://github.com/container-interop/container-interop",
|
||||||
|
"time": "2017-02-14T19:40:03+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "doctrine/annotations",
|
"name": "doctrine/annotations",
|
||||||
"version": "v1.6.0",
|
"version": "v1.6.0",
|
||||||
@ -1136,16 +1167,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "jms/metadata",
|
"name": "jms/metadata",
|
||||||
"version": "2.0.0-RC1",
|
"version": "2.0.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/schmittjoh/metadata.git",
|
"url": "https://github.com/schmittjoh/metadata.git",
|
||||||
"reference": "38021d33d9c54b135284abffe6dd8246c9b16863"
|
"reference": "e918c3a65105f73b74d94a0837b9f7d611d5bf0c"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/schmittjoh/metadata/zipball/38021d33d9c54b135284abffe6dd8246c9b16863",
|
"url": "https://api.github.com/repos/schmittjoh/metadata/zipball/e918c3a65105f73b74d94a0837b9f7d611d5bf0c",
|
||||||
"reference": "38021d33d9c54b135284abffe6dd8246c9b16863",
|
"reference": "e918c3a65105f73b74d94a0837b9f7d611d5bf0c",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -1189,7 +1220,7 @@
|
|||||||
"xml",
|
"xml",
|
||||||
"yaml"
|
"yaml"
|
||||||
],
|
],
|
||||||
"time": "2018-10-17T06:41:44+00:00"
|
"time": "2018-11-09T13:57:43+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "jms/serializer",
|
"name": "jms/serializer",
|
||||||
@ -1277,16 +1308,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "monolog/monolog",
|
"name": "monolog/monolog",
|
||||||
"version": "1.23.0",
|
"version": "1.24.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/Seldaek/monolog.git",
|
"url": "https://github.com/Seldaek/monolog.git",
|
||||||
"reference": "fd8c787753b3a2ad11bc60c063cff1358a32a3b4"
|
"reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/fd8c787753b3a2ad11bc60c063cff1358a32a3b4",
|
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266",
|
||||||
"reference": "fd8c787753b3a2ad11bc60c063cff1358a32a3b4",
|
"reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -1351,20 +1382,20 @@
|
|||||||
"logging",
|
"logging",
|
||||||
"psr-3"
|
"psr-3"
|
||||||
],
|
],
|
||||||
"time": "2017-06-19T01:22:40+00:00"
|
"time": "2018-11-05T09:00:11+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "nesbot/carbon",
|
"name": "nesbot/carbon",
|
||||||
"version": "1.34.0",
|
"version": "1.34.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/briannesbitt/Carbon.git",
|
"url": "https://github.com/briannesbitt/Carbon.git",
|
||||||
"reference": "1dbd3cb01c5645f3e7deda7aa46ef780d95fcc33"
|
"reference": "19201b87f7dba2a7cbf1cccdf0e1da13c04ee9c9"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/1dbd3cb01c5645f3e7deda7aa46ef780d95fcc33",
|
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/19201b87f7dba2a7cbf1cccdf0e1da13c04ee9c9",
|
||||||
"reference": "1dbd3cb01c5645f3e7deda7aa46ef780d95fcc33",
|
"reference": "19201b87f7dba2a7cbf1cccdf0e1da13c04ee9c9",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -1406,7 +1437,7 @@
|
|||||||
"datetime",
|
"datetime",
|
||||||
"time"
|
"time"
|
||||||
],
|
],
|
||||||
"time": "2018-09-20T19:36:25+00:00"
|
"time": "2018-11-08T13:33:47+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "ocramius/proxy-manager",
|
"name": "ocramius/proxy-manager",
|
||||||
@ -1521,6 +1552,55 @@
|
|||||||
],
|
],
|
||||||
"time": "2015-07-25T16:39:46+00:00"
|
"time": "2015-07-25T16:39:46+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "psr/container",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/php-fig/container.git",
|
||||||
|
"reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
|
||||||
|
"reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.3.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "1.0.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Psr\\Container\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "PHP-FIG",
|
||||||
|
"homepage": "http://www.php-fig.org/"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Common Container Interface (PHP FIG PSR-11)",
|
||||||
|
"homepage": "https://github.com/php-fig/container",
|
||||||
|
"keywords": [
|
||||||
|
"PSR-11",
|
||||||
|
"container",
|
||||||
|
"container-interface",
|
||||||
|
"container-interop",
|
||||||
|
"psr"
|
||||||
|
],
|
||||||
|
"time": "2017-02-14T16:28:37+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "psr/log",
|
"name": "psr/log",
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
@ -1974,16 +2054,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/filesystem",
|
"name": "symfony/filesystem",
|
||||||
"version": "v2.8.46",
|
"version": "v2.8.47",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/filesystem.git",
|
"url": "https://github.com/symfony/filesystem.git",
|
||||||
"reference": "91f194c5ec8d2ad5ce417a218ce3c46909e92f4d"
|
"reference": "56a92481a4969b234b1647b1fd1170281e80e2ca"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/filesystem/zipball/91f194c5ec8d2ad5ce417a218ce3c46909e92f4d",
|
"url": "https://api.github.com/repos/symfony/filesystem/zipball/56a92481a4969b234b1647b1fd1170281e80e2ca",
|
||||||
"reference": "91f194c5ec8d2ad5ce417a218ce3c46909e92f4d",
|
"reference": "56a92481a4969b234b1647b1fd1170281e80e2ca",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -2020,11 +2100,11 @@
|
|||||||
],
|
],
|
||||||
"description": "Symfony Filesystem Component",
|
"description": "Symfony Filesystem Component",
|
||||||
"homepage": "https://symfony.com",
|
"homepage": "https://symfony.com",
|
||||||
"time": "2018-09-24T08:04:37+00:00"
|
"time": "2018-10-02T03:12:00+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/polyfill-ctype",
|
"name": "symfony/polyfill-ctype",
|
||||||
"version": "v1.9.0",
|
"version": "v1.10.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/polyfill-ctype.git",
|
"url": "https://github.com/symfony/polyfill-ctype.git",
|
||||||
@ -2082,16 +2162,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/polyfill-mbstring",
|
"name": "symfony/polyfill-mbstring",
|
||||||
"version": "v1.9.0",
|
"version": "v1.10.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/polyfill-mbstring.git",
|
"url": "https://github.com/symfony/polyfill-mbstring.git",
|
||||||
"reference": "d0cd638f4634c16d8df4508e847f14e9e43168b8"
|
"reference": "c79c051f5b3a46be09205c73b80b346e4153e494"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/d0cd638f4634c16d8df4508e847f14e9e43168b8",
|
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/c79c051f5b3a46be09205c73b80b346e4153e494",
|
||||||
"reference": "d0cd638f4634c16d8df4508e847f14e9e43168b8",
|
"reference": "c79c051f5b3a46be09205c73b80b346e4153e494",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -2137,20 +2217,20 @@
|
|||||||
"portable",
|
"portable",
|
||||||
"shim"
|
"shim"
|
||||||
],
|
],
|
||||||
"time": "2018-08-06T14:22:27+00:00"
|
"time": "2018-09-21T13:07:52+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/process",
|
"name": "symfony/process",
|
||||||
"version": "v2.8.46",
|
"version": "v2.8.47",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/process.git",
|
"url": "https://github.com/symfony/process.git",
|
||||||
"reference": "f09e21b7c5aba06c47bbfad9cbcf13ac7f0db0a6"
|
"reference": "a15cb61190c6fe37168600922e82295eb5e5449b"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/process/zipball/f09e21b7c5aba06c47bbfad9cbcf13ac7f0db0a6",
|
"url": "https://api.github.com/repos/symfony/process/zipball/a15cb61190c6fe37168600922e82295eb5e5449b",
|
||||||
"reference": "f09e21b7c5aba06c47bbfad9cbcf13ac7f0db0a6",
|
"reference": "a15cb61190c6fe37168600922e82295eb5e5449b",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -2186,20 +2266,20 @@
|
|||||||
],
|
],
|
||||||
"description": "Symfony Process Component",
|
"description": "Symfony Process Component",
|
||||||
"homepage": "https://symfony.com",
|
"homepage": "https://symfony.com",
|
||||||
"time": "2018-09-06T17:11:15+00:00"
|
"time": "2018-10-05T07:35:28+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/translation",
|
"name": "symfony/translation",
|
||||||
"version": "v4.1.6",
|
"version": "v4.1.7",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/translation.git",
|
"url": "https://github.com/symfony/translation.git",
|
||||||
"reference": "9f0b61e339160a466ebcde167a6c5521c810e304"
|
"reference": "aa04dc1c75b7d3da7bd7003104cd0cfc5dff635c"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/translation/zipball/9f0b61e339160a466ebcde167a6c5521c810e304",
|
"url": "https://api.github.com/repos/symfony/translation/zipball/aa04dc1c75b7d3da7bd7003104cd0cfc5dff635c",
|
||||||
"reference": "9f0b61e339160a466ebcde167a6c5521c810e304",
|
"reference": "aa04dc1c75b7d3da7bd7003104cd0cfc5dff635c",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -2255,11 +2335,11 @@
|
|||||||
],
|
],
|
||||||
"description": "Symfony Translation Component",
|
"description": "Symfony Translation Component",
|
||||||
"homepage": "https://symfony.com",
|
"homepage": "https://symfony.com",
|
||||||
"time": "2018-10-02T16:36:10+00:00"
|
"time": "2018-10-28T18:38:52+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/yaml",
|
"name": "symfony/yaml",
|
||||||
"version": "v4.1.6",
|
"version": "v4.1.7",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/yaml.git",
|
"url": "https://github.com/symfony/yaml.git",
|
||||||
@ -2517,6 +2597,123 @@
|
|||||||
"zf2"
|
"zf2"
|
||||||
],
|
],
|
||||||
"time": "2018-04-25T15:33:34+00:00"
|
"time": "2018-04-25T15:33:34+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "zendframework/zend-stdlib",
|
||||||
|
"version": "3.2.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/zendframework/zend-stdlib.git",
|
||||||
|
"reference": "66536006722aff9e62d1b331025089b7ec71c065"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/zendframework/zend-stdlib/zipball/66536006722aff9e62d1b331025089b7ec71c065",
|
||||||
|
"reference": "66536006722aff9e62d1b331025089b7ec71c065",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^5.6 || ^7.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpbench/phpbench": "^0.13",
|
||||||
|
"phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1.2",
|
||||||
|
"zendframework/zend-coding-standard": "~1.0.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "3.2.x-dev",
|
||||||
|
"dev-develop": "3.3.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Zend\\Stdlib\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"BSD-3-Clause"
|
||||||
|
],
|
||||||
|
"description": "SPL extensions, array utilities, error handlers, and more",
|
||||||
|
"keywords": [
|
||||||
|
"ZendFramework",
|
||||||
|
"stdlib",
|
||||||
|
"zf"
|
||||||
|
],
|
||||||
|
"time": "2018-08-28T21:34:05+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "zendframework/zend-validator",
|
||||||
|
"version": "2.10.2",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/zendframework/zend-validator.git",
|
||||||
|
"reference": "38109ed7d8e46cfa71bccbe7e6ca80cdd035f8c9"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/zendframework/zend-validator/zipball/38109ed7d8e46cfa71bccbe7e6ca80cdd035f8c9",
|
||||||
|
"reference": "38109ed7d8e46cfa71bccbe7e6ca80cdd035f8c9",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"container-interop/container-interop": "^1.1",
|
||||||
|
"php": "^5.6 || ^7.0",
|
||||||
|
"zendframework/zend-stdlib": "^2.7.6 || ^3.1"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "^6.0.8 || ^5.7.15",
|
||||||
|
"zendframework/zend-cache": "^2.6.1",
|
||||||
|
"zendframework/zend-coding-standard": "~1.0.0",
|
||||||
|
"zendframework/zend-config": "^2.6",
|
||||||
|
"zendframework/zend-db": "^2.7",
|
||||||
|
"zendframework/zend-filter": "^2.6",
|
||||||
|
"zendframework/zend-http": "^2.5.4",
|
||||||
|
"zendframework/zend-i18n": "^2.6",
|
||||||
|
"zendframework/zend-math": "^2.6",
|
||||||
|
"zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3",
|
||||||
|
"zendframework/zend-session": "^2.8",
|
||||||
|
"zendframework/zend-uri": "^2.5"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"zendframework/zend-db": "Zend\\Db component, required by the (No)RecordExists validator",
|
||||||
|
"zendframework/zend-filter": "Zend\\Filter component, required by the Digits validator",
|
||||||
|
"zendframework/zend-i18n": "Zend\\I18n component to allow translation of validation error messages",
|
||||||
|
"zendframework/zend-i18n-resources": "Translations of validator messages",
|
||||||
|
"zendframework/zend-math": "Zend\\Math component, required by the Csrf validator",
|
||||||
|
"zendframework/zend-servicemanager": "Zend\\ServiceManager component to allow using the ValidatorPluginManager and validator chains",
|
||||||
|
"zendframework/zend-session": "Zend\\Session component, ^2.8; required by the Csrf validator",
|
||||||
|
"zendframework/zend-uri": "Zend\\Uri component, required by the Uri and Sitemap\\Loc validators"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "2.10.x-dev",
|
||||||
|
"dev-develop": "2.11.x-dev"
|
||||||
|
},
|
||||||
|
"zf": {
|
||||||
|
"component": "Zend\\Validator",
|
||||||
|
"config-provider": "Zend\\Validator\\ConfigProvider"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Zend\\Validator\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"BSD-3-Clause"
|
||||||
|
],
|
||||||
|
"description": "provides a set of commonly needed validators",
|
||||||
|
"homepage": "https://github.com/zendframework/zend-validator",
|
||||||
|
"keywords": [
|
||||||
|
"validator",
|
||||||
|
"zf2"
|
||||||
|
],
|
||||||
|
"time": "2018-02-01T17:05:33+00:00"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [
|
"packages-dev": [
|
||||||
|
43
src/CalendarProcessor.php
Normal file
43
src/CalendarProcessor.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Aerex\TaskwarriorPlugin\Processors;
|
||||||
|
use Aerex\TaskwarriorPlugin\TaskwarriorManager;
|
||||||
|
use Sabre\VObject\Component\VTodo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ToDo
|
||||||
|
*
|
||||||
|
* @author Aerex
|
||||||
|
*/
|
||||||
|
class CalendarProcessor
|
||||||
|
{
|
||||||
|
|
||||||
|
public function __construct(TaskwarriorManager $taskwarriorManager){
|
||||||
|
$this->taskwarriorManager = $taskwarriorManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function importTask(VTodo $Todo){
|
||||||
|
|
||||||
|
if($this->taskwarriorManager->exists($Todo->UID)){
|
||||||
|
$this->taskwarriorManager->updateTask($Todo);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->taskwarriorManager->addTask($Todo);
|
||||||
|
|
||||||
|
} catch(Exception $e){
|
||||||
|
echo $e->getMessage();
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export(){
|
||||||
|
echo "Not yet implemented";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Aerex\TaskwarriorPlugin;
|
namespace Aerex\TaskwarriorPlugin\Configuration;
|
||||||
|
|
||||||
use DavidBadura\Taskwarrior\Taskwarrior;
|
use DavidBadura\Taskwarrior\Taskwarrior;
|
||||||
use Aerex\TaskwarriorPlugin\TaskwarriorManager;
|
use Aerex\TaskwarriorPlugin\TaskwarriorManager;
|
||||||
|
@ -3,13 +3,13 @@
|
|||||||
namespace Aerex\TaskwarriorPlugin;
|
namespace Aerex\TaskwarriorPlugin;
|
||||||
|
|
||||||
use Sabre\DAV\Exception\BadRequest;
|
use Sabre\DAV\Exception\BadRequest;
|
||||||
use Sabre\VObject\Document;
|
use Sabre\VObject\Component\VCalendar;
|
||||||
use Sabre\HTTP\RequestInterface;
|
use Sabre\HTTP\RequestInterface;
|
||||||
use Sabre\HTTP\ResponseInterface;
|
use Sabre\HTTP\ResponseInterface;
|
||||||
use Sabre\Xml\ParseException;
|
use Sabre\Xml\ParseException;
|
||||||
use Sabre\DAV\ServerPlugin;
|
use Sabre\DAV\ServerPlugin;
|
||||||
use Sabre\DAV\Server;
|
use Sabre\DAV\Server;
|
||||||
use Aerex\TaskwarriorPlugin\iCalEventProcessor;
|
use Aerex\TaskwarriorPlugin\CalendarProcessor;
|
||||||
use Aerex\TaskwarriorPlugin\Config;
|
use Aerex\TaskwarriorPlugin\Config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -49,7 +49,7 @@ class Plugin extends ServerPlugin {
|
|||||||
if(!is_null($TWCalManager)){
|
if(!is_null($TWCalManager)){
|
||||||
$this->twCalManager = $TWCalManager;
|
$this->twCalManager = $TWCalManager;
|
||||||
} else {
|
} else {
|
||||||
$this->twCalManager = new iCalEventProcessor();
|
$this->twCalManager = new CalendarProcessor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ class Plugin extends ServerPlugin {
|
|||||||
*
|
*
|
||||||
* @param VCalendar $vCal parsed calendar object
|
* @param VCalendar $vCal parsed calendar object
|
||||||
*/
|
*/
|
||||||
function processCalendarEventForTaskwarrior(Document $vCal){
|
function processCalendarEventForTaskwarrior(VCalendar $vCal){
|
||||||
try {
|
try {
|
||||||
$this->twCalManager->importTask($vCal->VTODO);
|
$this->twCalManager->importTask($vCal->VTODO);
|
||||||
} catch(BadRequest $e){
|
} catch(BadRequest $e){
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace ;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface CalendarComponent
|
|
||||||
* @author Aerex
|
|
||||||
*/
|
|
||||||
interface CalendarComponentInterface
|
|
||||||
{
|
|
||||||
public function import();
|
|
||||||
public function export();
|
|
||||||
?>
|
|
@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Aerex\TaskwarriorPlugin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class iCalEvent
|
|
||||||
*
|
|
||||||
* @author yourname
|
|
||||||
*/
|
|
||||||
class ToDo implements CalendarComponentInterface
|
|
||||||
{
|
|
||||||
public
|
|
||||||
|
|
||||||
public function import(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
|
29
src/Task.php
29
src/Task.php
@ -1,29 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Aerex\TaskwarriorPlugin;
|
|
||||||
use DavidBadura\Taskwarrior\Task as BasicTask;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Task
|
|
||||||
* @author Aerex
|
|
||||||
*/
|
|
||||||
class Task extends BasicTask {
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* If description is not available attempt to summary, otherwise throw Exception
|
|
||||||
*/
|
|
||||||
public function setDescription(VTodo $toDoComponent){
|
|
||||||
|
|
||||||
if(!isset($ToDoComponent->DESCRIPTION) && isset($ToDoComponent->SUMMARY)){
|
|
||||||
$description = $summary;
|
|
||||||
} else if(!isset($ToDoComponent->DESCRIPTION) && !isset($ToDoComponent->SUMMARY)){
|
|
||||||
throw new Exception("Task must have a description or summary");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public
|
|
||||||
|
|
||||||
}
|
|
10
src/Taskwarrior/Commands/IStrategy.php
Normal file
10
src/Taskwarrior/Commands/IStrategy.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
namespace Aerex\TaskwarriorPlugin\Taskwarrior\Commands;
|
||||||
|
|
||||||
|
use Aerex\TaskwarriorPlugin\Taskwarrior\Task;
|
||||||
|
|
||||||
|
interface Strategy {
|
||||||
|
public function add(Task $task);
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
62
src/Taskwarrior/Commands/TodoStrategy.php
Normal file
62
src/Taskwarrior/Commands/TodoStrategy.php
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
class TodoStrategy implements IStrategy {
|
||||||
|
|
||||||
|
public function __construct(TaskwarriorConfig $config){
|
||||||
|
$this->config = $config;
|
||||||
|
$this->cmd[] = $this->config->taskBin();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function add(Task $task){
|
||||||
|
$this->cmd[] = 'add';
|
||||||
|
|
||||||
|
if($task->getDescription() != null){
|
||||||
|
$this->cmd[] = sprintf('"%s"', $task->getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
if($task->getCategories() != null){
|
||||||
|
$categories = implode(' +', $task->getCategories());
|
||||||
|
$this->cmd[] = $categories;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($task->getDue() != null){
|
||||||
|
$this->cmd[] = $task->getDue('Y-m-dTH:i:s');
|
||||||
|
}
|
||||||
|
|
||||||
|
if($task->getRecurrence() != null){
|
||||||
|
$rrule = $task->getRecurrence()->getParts();
|
||||||
|
$this->cmd[] = sprintf('recur:%s', $rrule['FREQ']);
|
||||||
|
if(isset($rrule['UNTIL'])){
|
||||||
|
$this->cmd[] = sprintf('until:%s', $rrule['UNTIL']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if($task->getStatus() != null){
|
||||||
|
$this->cmd[] = sprintf('status:%s', $task->getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->executeCommand($cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private function executeCommand($command){
|
||||||
|
|
||||||
|
|
||||||
|
$cmdString = implode(' ', $command);
|
||||||
|
$process = new Process($cmdString);
|
||||||
|
|
||||||
|
$process->run();
|
||||||
|
|
||||||
|
if(!$process->isSuccessful()){
|
||||||
|
throw new TaskwarriorCommandLineException($process);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $process->getOutput();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
264
src/Taskwarrior/Task.php
Normal file
264
src/Taskwarrior/Task.php
Normal file
@ -0,0 +1,264 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Aerex\TaskwarriorPlugin\Taskwarrior;
|
||||||
|
use Zend\Validator\Uuid;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Sabre\VObject\Component\VTodo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Task
|
||||||
|
* @author Aerex
|
||||||
|
*/
|
||||||
|
class Task {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*
|
||||||
|
* @JMS\Type("string")
|
||||||
|
*/
|
||||||
|
private $uuid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*
|
||||||
|
* @JMS\Type("string")
|
||||||
|
*/
|
||||||
|
private $description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*
|
||||||
|
* @JMS\Type("string")
|
||||||
|
*/
|
||||||
|
private $priority;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*
|
||||||
|
* @JMS\Type("string")
|
||||||
|
*/
|
||||||
|
private $project;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Carbon
|
||||||
|
*
|
||||||
|
* @JMS\Type("Carbon")
|
||||||
|
*/
|
||||||
|
private $due;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Carbon
|
||||||
|
*
|
||||||
|
* @JMS\Type("Carbon")
|
||||||
|
*/
|
||||||
|
private $wait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*
|
||||||
|
* @JMS\Type("array<string>")
|
||||||
|
*/
|
||||||
|
private $tags;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var float
|
||||||
|
*
|
||||||
|
* @JMS\Type("float")
|
||||||
|
*/
|
||||||
|
private $urgency;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Carbon
|
||||||
|
*
|
||||||
|
* @JMS\Type("Carbon")
|
||||||
|
*/
|
||||||
|
private $entry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Carbon
|
||||||
|
*
|
||||||
|
* @JMS\Type("Carbon")
|
||||||
|
*/
|
||||||
|
private $start;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*
|
||||||
|
* @JMS\Type("Recurring")
|
||||||
|
*/
|
||||||
|
private $recur;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Carbon
|
||||||
|
*
|
||||||
|
* @JMS\Type("Carbon")
|
||||||
|
*/
|
||||||
|
private $until;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Annotation[]
|
||||||
|
*
|
||||||
|
* @JMS\Type("array<Aerex\Taskwarrior\Annotation>")
|
||||||
|
*/
|
||||||
|
private $annotations = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Carbon
|
||||||
|
*
|
||||||
|
* @JMS\Type("Carbon")
|
||||||
|
*/
|
||||||
|
private $modified;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Carbon
|
||||||
|
*
|
||||||
|
* @JMS\Type("Carbon")
|
||||||
|
*/
|
||||||
|
private $end;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*
|
||||||
|
* @JMS\Type("string")
|
||||||
|
*/
|
||||||
|
private $status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Task[]|ArrayCollection
|
||||||
|
*
|
||||||
|
* @JMS\Type("Depends")
|
||||||
|
*/
|
||||||
|
private $depends;
|
||||||
|
|
||||||
|
public function __construct($UUID=null){
|
||||||
|
$validator = new Uuid();
|
||||||
|
|
||||||
|
if(!isset($UUID)){
|
||||||
|
$this->uuid = uniqid();
|
||||||
|
} else if(isset($UUID) && !$validator->isValid($UUID)){
|
||||||
|
throw new Exception(sprintf('%s is not a valid uuid', $UUID));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->uuid = $UUID;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* If description is not available attempt to summary, otherwise throw Exception
|
||||||
|
*/
|
||||||
|
public function setDescription(VTodo $component){
|
||||||
|
if(!isset($component->DESCRIPTION) && isset($component->SUMMARY)){
|
||||||
|
$this->description = $component->SUMMARY;
|
||||||
|
} else if(!isset($component->DESCRIPTION) && !isset($component->SUMMARY)){
|
||||||
|
throw new Exception("Task must have a description or summary");
|
||||||
|
} else {
|
||||||
|
$this->description = $component->DESCRIPTION;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDescription(){
|
||||||
|
return $this->description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setEntryTime(VTodo $document){
|
||||||
|
|
||||||
|
if(isset($document->DTSTAMP)){
|
||||||
|
$this->entry = new Carbon($document->DTSTAMP->getDateTime()->format(\DateTime::W3C));
|
||||||
|
} else {
|
||||||
|
throw new Exception('Task must have a entry time');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEntryTime(){
|
||||||
|
return $this->entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setStartTime(VTodo $document){
|
||||||
|
if(isset($document->DTSTART)){
|
||||||
|
$this->start = new Carbon($document->DTSTART->getDateTime()->format(\DateTime::W3C));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStartTime(){
|
||||||
|
return $this->start;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setModifiedTime(VTodo $document){
|
||||||
|
if(isset($document->{'LAST-MODIFIED'})){
|
||||||
|
$this->modified = new Carbon($document->{'LAST-MODIFIED'}->getDateTime()->format(\DateTime::W3C));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getModifiedTime(){
|
||||||
|
return $this->modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDue(VTodo $document){
|
||||||
|
|
||||||
|
if(isset($document->DUE)){
|
||||||
|
$this->due = new Carbon($document->DUE->getDateTime()->format(\DateTime::W3C));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function getDue(){
|
||||||
|
return $this->due;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setStopTime(VTodo $document){
|
||||||
|
if(isset($document->DTEND)){
|
||||||
|
$this->end = new Carbon($document->DTEND->getDateTime()->format(\DateTime::W3C));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStopTime(){
|
||||||
|
return $this->end;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCategories(VTodo $document){
|
||||||
|
if(isset($document->CATEGORIES)){
|
||||||
|
$this->tags = explode(',', (string)$document->CATEGORIES);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCategories(){
|
||||||
|
return $this->tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setStatus(VTodo $document){
|
||||||
|
if(isset($document->STATUS)){
|
||||||
|
switch((string)$document->STATUS){
|
||||||
|
case 'NEEDS-ACTION':
|
||||||
|
$this->status = 'pending';
|
||||||
|
break;
|
||||||
|
case 'COMPLETED':
|
||||||
|
$this->status = 'completed';
|
||||||
|
break;
|
||||||
|
case 'CANCELED':
|
||||||
|
$this->status = 'deleted';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setRecurrence(VTodo $document){
|
||||||
|
if(isset($document->RRULE)){
|
||||||
|
$this->recur = $document->RRULE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStatus(){
|
||||||
|
return $this->status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
66
src/Taskwarrior/Taskwarrior.php
Normal file
66
src/Taskwarrior/Taskwarrior.php
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Aerex\TaskwarriorPlugin\Taskwarrior;
|
||||||
|
use Symfony\Component\Process\Process;
|
||||||
|
use Aerex\TaskwarriorPlugin\Commands\IStrategy;
|
||||||
|
|
||||||
|
class Taskwarrior {
|
||||||
|
|
||||||
|
const EXPORT = 'export';
|
||||||
|
const IMPORT = 'import';
|
||||||
|
const ADD = 'add';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var TaskwarriorConfig
|
||||||
|
*/
|
||||||
|
private $config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $bin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $taskrc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $taskData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $rcOptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function __construct(TaskwarriorConfig $config){
|
||||||
|
if(!isset($config)){
|
||||||
|
$this->config = new TaskwarriorConfig();
|
||||||
|
}
|
||||||
|
$this->config = $config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setStrategy(IStrategy $strategy){
|
||||||
|
$this->strategy = $strategy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createTask($uuid){
|
||||||
|
$task = new Task($uuid);
|
||||||
|
return $task;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function add($task){
|
||||||
|
$this->strategy($task);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
158
src/Taskwarrior/TaskwarriorManager.php
Normal file
158
src/Taskwarrior/TaskwarriorManager.php
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Aerex\TaskwarriorPlugin;
|
||||||
|
|
||||||
|
use Aerex\TaskwarriorPlugin\Taskwarrior;
|
||||||
|
use Sabre\VObject\Component\VTodo;
|
||||||
|
use DavidBadura\Taskwarrior\TaskManager;
|
||||||
|
use DavidBadura\Taskwarrior\Task;
|
||||||
|
|
||||||
|
class TaskwarriorManager {
|
||||||
|
|
||||||
|
const DESCRIPTION = 'description';
|
||||||
|
const CATEGORIES = 'categories';
|
||||||
|
const TASK_UUID = 'uuid';
|
||||||
|
const ICAL_UID = 'uid';
|
||||||
|
|
||||||
|
private $tasks;
|
||||||
|
|
||||||
|
const ENTRY = 'entry';
|
||||||
|
const START = 'start';
|
||||||
|
const MODIFIED = 'modified';
|
||||||
|
const END = 'end';
|
||||||
|
|
||||||
|
public function __construct($taskwarrior){
|
||||||
|
parent::__construct($taskwarrior);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createTask($UUID){
|
||||||
|
$task = new Task();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export(VTodo $document){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addTask(VTodo $document){
|
||||||
|
|
||||||
|
$task = $this->taskwarrior->createTask($document->UID);
|
||||||
|
|
||||||
|
$task->setDescription($document);
|
||||||
|
|
||||||
|
$task->setEntry($document);
|
||||||
|
|
||||||
|
$task->setStartTime($document);
|
||||||
|
|
||||||
|
$task->setModifiedTime($document);
|
||||||
|
|
||||||
|
$task->setStopTime($document);
|
||||||
|
|
||||||
|
$task->setDue($document);
|
||||||
|
|
||||||
|
$task->setCategories($document);
|
||||||
|
|
||||||
|
$task->setStatus($document);
|
||||||
|
|
||||||
|
$task->setRecurrence($document);
|
||||||
|
|
||||||
|
return $this->taskwarrior->add($task);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateTask(VTodo $document){
|
||||||
|
|
||||||
|
$task = $this->taskwarrior->get($document->UID);
|
||||||
|
|
||||||
|
$task->setDescription($document);
|
||||||
|
|
||||||
|
$task->setEntry($document);
|
||||||
|
|
||||||
|
$task->setStartTime($document);
|
||||||
|
|
||||||
|
$task->setModifiedTime($document);
|
||||||
|
|
||||||
|
$task->setStopTime($document);
|
||||||
|
|
||||||
|
$task->setDue($document);
|
||||||
|
|
||||||
|
$task->setCategories($document);
|
||||||
|
|
||||||
|
$task->setStatus($document);
|
||||||
|
|
||||||
|
$task->setRecurrence($document);
|
||||||
|
|
||||||
|
$updatedTask = $this->taskwarrior->modify($task);
|
||||||
|
|
||||||
|
return $upatedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function setEntryTime($entry){
|
||||||
|
}
|
||||||
|
|
||||||
|
function exists($UUID){}
|
||||||
|
|
||||||
|
function setEndTime($end){}
|
||||||
|
function setModifiedTime($modifiedTime){}
|
||||||
|
function setSummary($description){
|
||||||
|
if(!isset($description)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->taskWarriorJSON[self::DESCRIPTION] = $description;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setStartTime($startTime){}
|
||||||
|
function setCategories($categories){
|
||||||
|
if(!isset($categories)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!is_array($catergories)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->taskWarriorJSON[self::CATEGORIES] = $categories;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function taskExists($taskUuid){
|
||||||
|
$taskIsInCache = isset($this->cachedTasks[$taskUuid]);
|
||||||
|
|
||||||
|
if($taskIsInCache){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$jsonArray = $this->taskwarrior->export($taskUuid);
|
||||||
|
$taskWithUuidExists = count($jsonArray) > 0;
|
||||||
|
|
||||||
|
return $taskWithUuidExists;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function save(){
|
||||||
|
|
||||||
|
}
|
||||||
|
public function build(){
|
||||||
|
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param Task $task
|
||||||
|
* @param string $attr
|
||||||
|
* @param mixed $value
|
||||||
|
*/
|
||||||
|
public function setValue(Task $task, $attr, $value)
|
||||||
|
{
|
||||||
|
$refClass = new \ReflectionClass(Task::class);
|
||||||
|
$refProp = $refClass->getProperty($attr);
|
||||||
|
$refProp->setAccessible(true);
|
||||||
|
$refProp->setValue($task, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function setDescription($description){}
|
||||||
|
function parseiCalDateTime($iCalDateTime){}
|
||||||
|
function convertToStringArray($categories){}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -1,112 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Aerex\TaskwarriorPlugin;
|
|
||||||
|
|
||||||
use Aerex\TaskwarriorPlugin\Taskwarrior;
|
|
||||||
use DavidBadura\Taskwarrior\TaskManager;
|
|
||||||
use DavidBadura\Taskwarrior\Task;
|
|
||||||
|
|
||||||
class TaskwarriorManager extends TaskManager {
|
|
||||||
|
|
||||||
const DESCRIPTION = 'description';
|
|
||||||
const CATEGORIES = 'categories';
|
|
||||||
const TASK_UUID = 'uuid';
|
|
||||||
const ICAL_UID = 'uid';
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @var \DavidBadura\Taskwarrior\Task
|
|
||||||
*/
|
|
||||||
private $tasks;
|
|
||||||
|
|
||||||
const ENTRY = 'entry';
|
|
||||||
const START = 'start';
|
|
||||||
const MODIFIED = 'modified';
|
|
||||||
const END = 'end';
|
|
||||||
|
|
||||||
public function __construct($taskwarrior){
|
|
||||||
parent::__construct($taskwarrior);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createTask($UUID){
|
|
||||||
$task = new Task();
|
|
||||||
$this->setValue($task, $ICAL_UID, $UUID);
|
|
||||||
return $task;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function export(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function setEntryTime($entry){
|
|
||||||
}
|
|
||||||
|
|
||||||
function exists($UUID){}
|
|
||||||
|
|
||||||
function setEndTime($end){}
|
|
||||||
function setModifiedTime($modifiedTime){}
|
|
||||||
function setSummary($description){
|
|
||||||
if(!isset($description)){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$this->taskWarriorJSON[self::DESCRIPTION] = $description;
|
|
||||||
}
|
|
||||||
|
|
||||||
function setStartTime($startTime){}
|
|
||||||
function setCategories($categories){
|
|
||||||
if(!isset($categories)){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!is_array($catergories)){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->taskWarriorJSON[self::CATEGORIES] = $categories;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function taskExists($taskUuid){
|
|
||||||
$taskIsInCache = isset($this->cachedTasks[$taskUuid]);
|
|
||||||
|
|
||||||
if($taskIsInCache){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$jsonArray = $this->taskwarrior->export($taskUuid);
|
|
||||||
$taskWithUuidExists = count($jsonArray) > 0;
|
|
||||||
|
|
||||||
return $taskWithUuidExists;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function save(){
|
|
||||||
|
|
||||||
}
|
|
||||||
public function build(){
|
|
||||||
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @param Task $task
|
|
||||||
* @param string $attr
|
|
||||||
* @param mixed $value
|
|
||||||
*/
|
|
||||||
public function setValue(Task $task, $attr, $value)
|
|
||||||
{
|
|
||||||
$refClass = new \ReflectionClass(Task::class);
|
|
||||||
$refProp = $refClass->getProperty($attr);
|
|
||||||
$refProp->setAccessible(true);
|
|
||||||
$refProp->setValue($task, $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function setDescription($description){}
|
|
||||||
function parseiCalDateTime($iCalDateTime){}
|
|
||||||
function convertToStringArray($categories){}
|
|
||||||
function setDueDate($dueDate){}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
@ -1,9 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
class TaskwarriorProps {
|
|
||||||
static $DESCRIPTION = 'description';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
|
@ -1,159 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Aerex\TaskwarriorPlugin;
|
|
||||||
|
|
||||||
use Aerex\TaskwarriorPlugin\Config;
|
|
||||||
use Sabre\DAV\Exception;
|
|
||||||
use Sabre\VObject\Component\VEvent;
|
|
||||||
use Sabre\VObject\Component\VTodo;
|
|
||||||
|
|
||||||
|
|
||||||
class iCalEventProcessor {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Config
|
|
||||||
*/
|
|
||||||
private $config;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private $taskrc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
|
|
||||||
private $taskDataDir;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private $cachedTasks = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
|
|
||||||
private $taskBinFile;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Taskwarrior
|
|
||||||
*/
|
|
||||||
|
|
||||||
private $taskwarrior;
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(Config $taskConfig = null){
|
|
||||||
if(!is_null($taskConfig)){
|
|
||||||
$this->taskConfig = $taskConfig;
|
|
||||||
} else {
|
|
||||||
$this->taskConfig = new Config();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->taskwarrior = $this->taskConfig->getTaskwarriorInstance();
|
|
||||||
$this->logger = $this->taskConfig->getLogger();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function importTask(VTodo $ToDoComponent = null){
|
|
||||||
|
|
||||||
echo $ToDoComponent->serialize();
|
|
||||||
if(!isset($ToDoComponent)){
|
|
||||||
$this->logger->error("vCal ToDo component is not defined");
|
|
||||||
throw new Exception("vCal Todo component is not defined");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if($this->taskwarrior->exists($ToDoComponent->UID)){
|
|
||||||
$this->taskwarrior->updateTask($ToDoComponent);
|
|
||||||
$this->logger->error("Updating task " . (string)$ToDoComponent->UID);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
$task = $this->taskwarrior->createiCalTask($ToDoComponent->UID);
|
|
||||||
|
|
||||||
// get description
|
|
||||||
if(!isset($ToDoComponent->DESCRIPTION) && isset($ToDoComponent->SUMMARY)){
|
|
||||||
$description = $summary;
|
|
||||||
} else if(!isset($ToDoComponent->DESCRIPTION) && !isset($ToDoComponent->SUMMARY)){
|
|
||||||
throw new Exception("Task must have a description or summary");
|
|
||||||
}
|
|
||||||
|
|
||||||
$task->setDescription($ToDoComponent->DESCRIPTION);
|
|
||||||
|
|
||||||
|
|
||||||
// get start time
|
|
||||||
if(!isset($ToDoComponent->DTSTAMP) && isset($ToDoComponent->DSTART)){
|
|
||||||
$start = $this->taskwarrior->convertToCarbonDateTime($ToDoComponent->DTSTAMP);
|
|
||||||
$entry = $start;
|
|
||||||
} else if (!isset($ToDoComponent->DTSTAMP) && !isset($ToDoComponent->DSTART)){
|
|
||||||
throw new Exception("Task must have an entry or start time");
|
|
||||||
} else {
|
|
||||||
$entry = $this->taskwarrior->convertToCarbonDateTime($ToDoComponent->DTSTAMP);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->taskwarrior->setValue($task, $this->taskwarrior::ENTRY, $entry);
|
|
||||||
|
|
||||||
if(isset($ToDoComponent->DSTART)){
|
|
||||||
$start = $this->taskwarrior->convertToCarbonDateTime($ToDoComponent->DSTART);
|
|
||||||
$this->taskwarrior->setValue($task, $this->taskwarrior::START, $start);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($ToDoComponent->{'LAST-MODIFIED'})){
|
|
||||||
$modified = $this->taskwarrior->convertToCarbonDateTime($ToDoComponent->{'LAST-MODIFIED'});
|
|
||||||
$this->taskwarrior->setValue($task, $this->taskwarrior::MODIFIED, $modified);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($ToDoComponent->DTEND)){
|
|
||||||
$end = $this->taskwarrior->convertToCarbonDateTime($ToDoComponent->DTEND);
|
|
||||||
$this->taskwarrior->setValue($task, $this->taskwarrior::MODIFIED, $modified);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($ToDoComponent->DUE)){
|
|
||||||
$due = $this->taskwarrior->convertToCarbonDateTime($ToDoComponent->DUE);
|
|
||||||
$task->setDue($due);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($ToDoComponent->DTEND)){
|
|
||||||
$end = $this->taskwarrior->convertToCarbonDateTime($ToDoComponent->DTEND);
|
|
||||||
$this->taskwarrior->setValue($task, $this->taskwarrior::END, $end);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($ToDoComponent->CATEGORIES)){
|
|
||||||
$tags = $this->taskwarrior->convertToStringArray($ToDoComponent->CATEGORIES);
|
|
||||||
$task->setTags($tags);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->taskwarrior->save($task);
|
|
||||||
|
|
||||||
} catch(Exception $e){
|
|
||||||
echo $e->getMessage();
|
|
||||||
|
|
||||||
$this->logger->error($e->message);
|
|
||||||
throw $e;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
|
59
tests/Processors/TodoTest.php
Normal file
59
tests/Processors/TodoTest.php
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Sabre\DAV\Exception\BadRequest;
|
||||||
|
use Monolog\Logger;
|
||||||
|
use Aerex\TaskwarriorPlugin\TaskwarriorManager;
|
||||||
|
use Aerex\TaskwarriorPlugin\Processors\ToDo;
|
||||||
|
use Sabre\VObject\Component\VCalendar;
|
||||||
|
use DavidBadura\Taskwarrior\Task;
|
||||||
|
use DateTime;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class TodoTest extends \PHPUnit\Framework\TestCase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \PHPUnit_Framework_MockObject_MockObject
|
||||||
|
* */
|
||||||
|
private $mockTaskwarriorManager;
|
||||||
|
|
||||||
|
|
||||||
|
function setup(){
|
||||||
|
|
||||||
|
$this->mockTaskwarriorManager = $this->createMock(TaskwarriorManager::class);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function testImportAndAddTask(){
|
||||||
|
$uuid = '9f353281-1051-4c45-92db-462f5d353c76';
|
||||||
|
$mockVCalendar = new VCalendar();
|
||||||
|
$mockVTodo = $mockVCalendar->add('VTODO', ['UID' => $uuid]);
|
||||||
|
|
||||||
|
$this->mockTaskwarriorManager->expects($this->once())->method('exists')->with($this->equalTo($uuid))
|
||||||
|
->willReturn(false);
|
||||||
|
|
||||||
|
$this->mockTaskwarriorManager->expects($this->once())->method('addTask')->with($this->equalTo($mockVTodo));
|
||||||
|
$todo = new ToDo($this->mockTaskwarriorManager);
|
||||||
|
$todo->import($mockVTodo);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function testImportAndUpdateTask(){
|
||||||
|
$uuid = '9f353281-1051-4c45-92db-462f5d353c76';
|
||||||
|
|
||||||
|
$mockVCalendar = new VCalendar();
|
||||||
|
$mockVTodo = $mockVCalendar->add('VTODO', ['UID' => $uuid]);
|
||||||
|
|
||||||
|
$this->mockTaskwarriorManager->expects($this->once())->method('exists')
|
||||||
|
->willReturn(true);
|
||||||
|
|
||||||
|
|
||||||
|
$this->mockTaskwarriorManager->expects($this->once())->method('updateTask');
|
||||||
|
|
||||||
|
$todo = new ToDo($this->mockTaskwarriorManager);
|
||||||
|
$todo->import($mockVTodo);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
173
tests/TaskTest.php
Normal file
173
tests/TaskTest.php
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Sabre\VObject\Component\VCalendar;
|
||||||
|
use Sabre\DAV\Exception\BadRequest;
|
||||||
|
use Aerex\TaskwarriorPlugin\Taskwarrior\Task;
|
||||||
|
use Aerex\TaskwarriorPlugin\Plugin;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Aerex\TaskwarriorPlugin\Config;
|
||||||
|
use Sabre\DAV\Server;
|
||||||
|
use DateTime;
|
||||||
|
use DateTimeZone;
|
||||||
|
|
||||||
|
class TaskTest extends \PHPUnit\Framework\TestCase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Plugin
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private $plugin;
|
||||||
|
/**
|
||||||
|
* @var VCalendar
|
||||||
|
*/
|
||||||
|
private $cal;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Server
|
||||||
|
*/
|
||||||
|
private $server;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var TaskwarriorCalendarEvent
|
||||||
|
*/
|
||||||
|
private $mockTaskCalEvent;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function testSetDescriptionUsingDescription(){
|
||||||
|
$uuid = 'f987aa59-9031-4a7b-9cf3-6bfa4dc44a85';
|
||||||
|
$expectedDescription = 'This is a description';
|
||||||
|
|
||||||
|
$mockVCalendar = new VCalendar();
|
||||||
|
$mockVTodo = $mockVCalendar->add('VTODO', ['UID' => $uuid]);
|
||||||
|
|
||||||
|
$mockVTodo->DESCRIPTION = $expectedDescription;
|
||||||
|
|
||||||
|
|
||||||
|
$todo = new Task();
|
||||||
|
|
||||||
|
$todo->setDescription($mockVTodo);
|
||||||
|
$actualDescription = $todo->getDescription();
|
||||||
|
|
||||||
|
$this->assertEquals($expectedDescription, $actualDescription);
|
||||||
|
}
|
||||||
|
public function testSetDescriptionUsingSummary(){
|
||||||
|
$uuid = 'f987aa59-9031-4a7b-9cf3-6bfa4dc44a85';
|
||||||
|
$expectedDescription = 'This is a description';
|
||||||
|
|
||||||
|
$mockVCalendar = new VCalendar();
|
||||||
|
$mockVTodo = $mockVCalendar->add('VTODO', ['UID' => $uuid]);
|
||||||
|
|
||||||
|
$mockVTodo->SUMMARY = $expectedDescription;
|
||||||
|
|
||||||
|
|
||||||
|
$todo = new Task();
|
||||||
|
|
||||||
|
$todo->setDescription($mockVTodo);
|
||||||
|
$actualDescription = $todo->getDescription();
|
||||||
|
|
||||||
|
$this->assertEquals($expectedDescription, $actualDescription);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException Error
|
||||||
|
*/
|
||||||
|
public function testFailureSetDescription(){
|
||||||
|
$uuid = 'f987aa59-9031-4a7b-9cf3-6bfa4dc44a85';
|
||||||
|
$expectedDescription = 'This is a description';
|
||||||
|
|
||||||
|
$mockVCalendar = new VCalendar();
|
||||||
|
$mockVTodo = $mockVCalendar->add('VTODO', ['UID' => $uuid]);
|
||||||
|
|
||||||
|
$todo = new Task();
|
||||||
|
|
||||||
|
$todo->setDescription($mockVTodo);
|
||||||
|
$actualDescription = $todo->getDescription();
|
||||||
|
|
||||||
|
}
|
||||||
|
public function testSetEntryTime(){
|
||||||
|
$uuid = 'f987aa59-9031-4a7b-9cf3-6bfa4dc44a85';
|
||||||
|
$expectedEntryTime = new DateTime('2018-11-11');
|
||||||
|
|
||||||
|
$mockVCalendar = new VCalendar();
|
||||||
|
$mockVTodo = $mockVCalendar->add('VTODO', ['UID' => $uuid]);
|
||||||
|
$expectedCarbonDate = new Carbon($expectedEntryTime->format('Y-m-d'));
|
||||||
|
$mockVTodo->DTSTAMP = $expectedEntryTime;
|
||||||
|
|
||||||
|
$todo = new Task();
|
||||||
|
|
||||||
|
$todo->setEntryTime($mockVTodo);
|
||||||
|
$actualEntryTime = $todo->getEntryTime();
|
||||||
|
|
||||||
|
$this->assertEquals($expectedCarbonDate, $actualEntryTime);
|
||||||
|
}
|
||||||
|
public function testSetStartTime(){
|
||||||
|
$uuid = 'f987aa59-9031-4a7b-9cf3-6bfa4dc44a85';
|
||||||
|
$expectedStartTime = new DateTime('2018-11-11');
|
||||||
|
|
||||||
|
$mockVCalendar = new VCalendar();
|
||||||
|
$mockVTodo = $mockVCalendar->add('VTODO', ['UID' => $uuid]);
|
||||||
|
$expectedCarbonDate = new Carbon($expectedStartTime->format('Y-m-d'));
|
||||||
|
$mockVTodo->DTSTART = $expectedStartTime;
|
||||||
|
|
||||||
|
$todo = new Task();
|
||||||
|
|
||||||
|
$todo->setStartTime($mockVTodo);
|
||||||
|
$actualStartTime = $todo->getStartTime();
|
||||||
|
|
||||||
|
$this->assertEquals($expectedCarbonDate, $actualStartTime);
|
||||||
|
}
|
||||||
|
public function testSetModifiedTime(){
|
||||||
|
$uuid = '182a6301-98e6-44df-97eb-8c7620f25b43';
|
||||||
|
$expectedModifiedTime = new DateTime('2018-11-11');
|
||||||
|
|
||||||
|
$mockVCalendar = new VCalendar();
|
||||||
|
$mockVTodo = $mockVCalendar->add('VTODO', ['UID' => $uuid]);
|
||||||
|
$expectedCarbonDate = new Carbon($expectedModifiedTime->format('Y-m-d'));
|
||||||
|
$mockVTodo->{'LAST-MODIFIED'} = $expectedModifiedTime;
|
||||||
|
|
||||||
|
$todo = new Task();
|
||||||
|
|
||||||
|
$todo->setModifiedTime($mockVTodo);
|
||||||
|
$actualModifiedTime = $todo->getModifiedTime();
|
||||||
|
|
||||||
|
$this->assertEquals($expectedCarbonDate, $actualModifiedTime);
|
||||||
|
}
|
||||||
|
public function testSetDue(){
|
||||||
|
$uuid = 'dde78b02-97d9-4e11-8603-e0fc14474c7c';
|
||||||
|
$expectedDueTime = new DateTime('2018-11-11');
|
||||||
|
|
||||||
|
$mockVCalendar = new VCalendar();
|
||||||
|
$mockVTodo = $mockVCalendar->add('VTODO', ['UID' => $uuid]);
|
||||||
|
$expectedCarbonDate = new Carbon($expectedDueTime->format('Y-m-d'));
|
||||||
|
$mockVTodo->DUE = $expectedDueTime;
|
||||||
|
|
||||||
|
$todo = new Task();
|
||||||
|
|
||||||
|
$todo->setDue($mockVTodo);
|
||||||
|
$actualDue = $todo->getDue();
|
||||||
|
|
||||||
|
$this->assertEquals($expectedCarbonDate, $actualDue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSetCategories(){
|
||||||
|
|
||||||
|
$uuid = '182a6301-98e6-44df-97eb-8c7620f25b43';
|
||||||
|
$expectedCategories = array("home", "work");
|
||||||
|
|
||||||
|
$mockVCalendar = new VCalendar();
|
||||||
|
$mockVTodo = $mockVCalendar->add('VTODO', ['UID' => $uuid]);
|
||||||
|
$mockVTodo->CATEGORIES = $expectedCategories;
|
||||||
|
|
||||||
|
$todo = new Task();
|
||||||
|
|
||||||
|
$todo->setCategories($mockVTodo);
|
||||||
|
$actualCategories = $todo->getCategories();
|
||||||
|
|
||||||
|
$this->assertEquals($expectedCategories, $actualCategories);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,174 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Sabre\DAV\Exception\BadRequest;
|
|
||||||
use Monolog\Logger;
|
|
||||||
use Sabre\VObject\Component\VCalendar;
|
|
||||||
use Aerex\TaskwarriorPlugin\TaskwarriorManager;
|
|
||||||
use Aerex\TaskwarriorPlugin\iCalEventProcessor;
|
|
||||||
use Aerex\TaskwarriorPlugin\Config;
|
|
||||||
use DavidBadura\Taskwarrior\Task;
|
|
||||||
use DateTime;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class iCalEventProcessorTest extends \PHPUnit\Framework\TestCase {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \PHPUnit_Framework_MockObject_MockObject
|
|
||||||
* */
|
|
||||||
private $mockTaskwarrior;
|
|
||||||
|
|
||||||
/***
|
|
||||||
* @var \PHPUnit_Framework_MockObject_MockObject
|
|
||||||
*/
|
|
||||||
private $mockTaskwarriorConfig;
|
|
||||||
|
|
||||||
/***
|
|
||||||
* @var \PHPUnit_Framework__MockObject
|
|
||||||
*/
|
|
||||||
private $mockLogger;
|
|
||||||
|
|
||||||
function setup(){
|
|
||||||
|
|
||||||
$this->mockTaskwarrior = $this->createMock(TaskwarriorManager::class);
|
|
||||||
$this->mockTask = $this->createMock(Task::class);
|
|
||||||
$this->mockTaskwarriorConfig = $this->createMock(Config::class);
|
|
||||||
$this->mockLogger = $this->createMock(Logger::class);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function testConstructorWithConfig() {
|
|
||||||
$this->mockTaskwarriorConfig->expects($this->once())
|
|
||||||
->method('getTaskwarriorInstance')
|
|
||||||
->will($this->returnValue($this->mockTaskwarrior));
|
|
||||||
|
|
||||||
$this->taskCalEvent = new iCalEventProcessor($this->mockTaskwarriorConfig);
|
|
||||||
|
|
||||||
}
|
|
||||||
function testBuildToDoComponent(){
|
|
||||||
$uuid = '9f353281-1051-4c45-92db-462f5d353c76';
|
|
||||||
$startTime = new DateTime('2018-07-04');
|
|
||||||
$endTime = new DateTime('2018-07-06');
|
|
||||||
$modifiedTime = new DateTime('2018-08-05');
|
|
||||||
$categories = array('home', 'test');
|
|
||||||
$dueDate = new DateTime('2018-08-20');
|
|
||||||
$description = 'This is a simple todo';
|
|
||||||
|
|
||||||
$mockVCalendar = new VCalendar();
|
|
||||||
$mockVTodo = $mockVCalendar->add('VTODO', ['UID' => $uuid]);
|
|
||||||
$mockVTodo->add('DSTAMP', $startTime);
|
|
||||||
$mockVTodo->add('DUE', $dueDate);
|
|
||||||
$mockVTodo->add('LAST-MODIFIED',$modifiedTime);
|
|
||||||
$mockVTodo->add('DSTART', $startTime);
|
|
||||||
$mockVTodo->add('DTEND', $endTime);
|
|
||||||
$mockVTodo->add('DESCRIPTION', $description);
|
|
||||||
$mockVTodo->add('CATEGORIES', $categories);
|
|
||||||
|
|
||||||
// $this->mockTaskwarrior->expects($this->exactly(4))
|
|
||||||
// ->method('parseiCalDateTime')
|
|
||||||
// ->will($this->onConsecutiveCalls($startTime, $startTime, $modifiedTime, $endTime));
|
|
||||||
|
|
||||||
$this->mockTaskwarrior->expects($this->once())->method('createTask')->with($this->equalTo($uuid))
|
|
||||||
->willReturn($this->mockTask);
|
|
||||||
$this->mockTask->expects($this->once())->method('setDue')->with($this->equalTo($dueDate));
|
|
||||||
$this->mockTask->expects($this->once())->method('setDescription')->with($this->equalTo($description));
|
|
||||||
$this->mockTaskwarrior->expects($this->once())->method('convertToStringArray')->with($this->equalTo($mockVTodo->CATEGORIES))
|
|
||||||
->willReturn($categories);
|
|
||||||
|
|
||||||
$this->mockTask->expects($this->once())->method('setTags')
|
|
||||||
->with($this->equalTo($categories));
|
|
||||||
|
|
||||||
$this->mockTaskwarrior->expects($this->exactly(4))
|
|
||||||
->method('setValue');
|
|
||||||
|
|
||||||
$this->mockLogger->expects($this->never())->method('error');
|
|
||||||
|
|
||||||
$this->mockTaskwarriorConfig
|
|
||||||
->expects($this->once())
|
|
||||||
->method('getTaskwarriorInstance')
|
|
||||||
->will($this->returnValue($this->mockTaskwarrior));
|
|
||||||
|
|
||||||
$this
|
|
||||||
->mockTaskwarrior
|
|
||||||
->expects($this->once())
|
|
||||||
->method('save');
|
|
||||||
|
|
||||||
$twCalEvent = new iCalEventProcessor($this->mockTaskwarriorConfig);
|
|
||||||
$twCalEvent->importTask($mockVTodo);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException Sabre\DAV\Exception
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function testFailTaskNoComponentDefine(){
|
|
||||||
|
|
||||||
$this->mockTaskwarrior->expects($this->never())->method('createTask');
|
|
||||||
$this->mockTaskwarrior->expects($this->never())->method('setEntryTime');
|
|
||||||
$this->mockTaskwarrior->expects($this->never())->method('setEndTime');
|
|
||||||
$this->mockTaskwarrior->expects($this->never())->method('setDueDate');
|
|
||||||
$this->mockTaskwarrior->expects($this->never())->method('setSummary');
|
|
||||||
$this->mockTaskwarrior->expects($this->never())->method('setCategories');
|
|
||||||
$this->mockTaskwarrior->expects($this->never())->method('build');
|
|
||||||
$this->mockTaskwarrior->expects($this->never())->method('save');
|
|
||||||
$this->mockTaskwarrior->expects($this->never())->method('exists');
|
|
||||||
|
|
||||||
$this->mockTaskwarriorConfig->expects($this->once())->method('getTaskwarriorInstance')
|
|
||||||
->willReturn($this->mockTaskwarrior);
|
|
||||||
|
|
||||||
$this->mockLogger->expects($this->once())->method('error');
|
|
||||||
|
|
||||||
$this->mockTaskwarriorConfig->expects($this->once())->method('getLogger')
|
|
||||||
->willReturn($this->mockLogger);
|
|
||||||
|
|
||||||
$twCalEvent = new iCalEventProcessor($this->mockTaskwarriorConfig);
|
|
||||||
$twCalEvent->importTask();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException Sabre\DAV\Exception\BadRequest
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
function testFailTaskExists(){
|
|
||||||
$uuid = '9f353281-1051-4c45-92db-462f5d353c76';
|
|
||||||
|
|
||||||
$mockVCalendar = new VCalendar();
|
|
||||||
$mockVTodo = $mockVCalendar->add('VTODO', ['UID' => $uuid]);
|
|
||||||
$expectedErrorMessage = "already exists";
|
|
||||||
|
|
||||||
$this->mockTaskwarrior->expects($this->never())->method('createTask');
|
|
||||||
$this->mockTaskwarrior->expects($this->never())->method('setEntryTime');
|
|
||||||
$this->mockTaskwarrior->expects($this->never())->method('setEndTime');
|
|
||||||
$this->mockTaskwarrior->expects($this->never())->method('setDueDate');
|
|
||||||
$this->mockTaskwarrior->expects($this->never())->method('setSummary');
|
|
||||||
$this->mockTaskwarrior->expects($this->never())->method('setCategories');
|
|
||||||
$this->mockTaskwarrior->expects($this->never())->method('build');
|
|
||||||
$this->mockTaskwarrior->expects($this->never())->method('save');
|
|
||||||
|
|
||||||
$this->mockTaskwarrior->expects($this->once())->method('exists')
|
|
||||||
->willReturn(true);
|
|
||||||
|
|
||||||
$this->mockTaskwarriorConfig->expects($this->once())->method('getTaskwarriorInstance')
|
|
||||||
->willReturn($this->mockTaskwarrior);
|
|
||||||
|
|
||||||
$this->mockLogger->expects($this->once())->method('error');
|
|
||||||
|
|
||||||
$this->mockTaskwarriorConfig->expects($this->once())->method('getLogger')
|
|
||||||
->willReturn($this->mockLogger);
|
|
||||||
|
|
||||||
$twCalEvent = new iCalEventProcessor($this->mockTaskwarriorConfig);
|
|
||||||
$twCalEvent->importTask($mockVTodo);
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
|
Loading…
Reference in New Issue
Block a user