From 05b1291f77ae405e7e60dfaa826ad7bf5d12dab8 Mon Sep 17 00:00:00 2001 From: Brad Wilson Date: Wed, 23 May 2018 15:08:40 -0500 Subject: [PATCH] example and test updates - composer.json - composer.lock --- composer.json | 9 +- composer.lock | 480 +++++++++++++++++- example/Worker.php | 2 +- example/Worker/Delegate.php | 4 +- example/Worker/Delegate/AwareTrait.php | 4 +- example/Worker/Delegate/Factory.php | 4 +- .../Worker/Delegate/Factory/AwareTrait.php | 4 +- example/Worker/Delegate/FactoryInterface.php | 4 +- example/Worker/Delegate/Repository.php | 6 +- .../Worker/Delegate/Repository/AwareTrait.php | 4 +- .../Worker/Delegate/RepositoryInterface.php | 4 +- example/Worker/DelegateInterface.php | 4 +- example/Worker/Queue.php | 6 +- example/Worker/Queue/AwareTrait.php | 30 +- example/Worker/Queue/Message.php | 2 +- example/Worker/Queue/Message/AwareTrait.php | 18 +- example/Worker/Queue/Message/Factory.php | 13 +- .../Worker/Queue/Message/FactoryInterface.php | 12 + example/Worker/Queue/MessageArray.php | 26 +- .../Worker/Queue/MessageArrayInterface.php | 23 + example/Worker/Queue/MessageInterface.php | 3 +- example/Worker/QueueInterface.php | 4 +- example/WorkerInterface.php | 2 +- tests/Application/Process/Strategy/Mock.php | 2 +- tests/Application/Worker/Mock.php | 2 +- .../dataSet1/fixtures/1_job_types.yml | 4 +- .../dataSet1/fixtures/2_jobs.yml | 398 +++++++-------- .../dataSet2/fixtures/1_job_type.yml | 2 +- .../dataSet2/fixtures/2_job.yml | 80 +-- .../dataSet3/fixtures/1_job_type.yml | 2 +- .../dataSet3/fixtures/2_jobs.yml | 80 +-- .../ForemanInterfaceTest.php | 2 +- .../fixtures/workWorkers/1_job_types.yml | 4 +- .../fixtures/workWorkers/2_jobs.yml | 398 +++++++-------- 34 files changed, 1081 insertions(+), 561 deletions(-) create mode 100644 example/Worker/Queue/Message/FactoryInterface.php create mode 100644 example/Worker/Queue/MessageArrayInterface.php diff --git a/composer.json b/composer.json index 755867a0..b13ada0a 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,8 @@ "zendframework/zend-db": "^2.8", "dragonmantank/cron-expression": "^2.0", "ocramius/proxy-manager": "^2.1", - "neighborhoods/pylon": "^1.0" + "neighborhoods/pylon": "^1.0", + "doctrine/dbal": "^2.7" }, "require-dev": { "phpunit/phpunit": "^7.0", @@ -46,8 +47,8 @@ }, "autoload-dev": { "psr-4": { - "Neighborhoods\\Kojo\\Test\\": "tests", - "Neighborhoods\\Kojo\\Example\\": "example" + "Neighborhoods\\KojoTest\\": "tests", + "Neighborhoods\\KojoExample\\": "example" } } -} \ No newline at end of file +} diff --git a/composer.lock b/composer.lock index edc1a0ea..3c069de3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,486 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "7b28cb3df38bba660f2306f7aa5b7c91", + "content-hash": "ad76a5b871bb8e08602cd4d6bd8e70e0", "packages": [ + { + "name": "doctrine/annotations", + "version": "v1.6.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/annotations.git", + "reference": "c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5", + "reference": "c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5", + "shasum": "" + }, + "require": { + "doctrine/lexer": "1.*", + "php": "^7.1" + }, + "require-dev": { + "doctrine/cache": "1.*", + "phpunit/phpunit": "^6.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.6.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Docblock Annotations Parser", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "docblock", + "parser" + ], + "time": "2017-12-06T07:11:42+00:00" + }, + { + "name": "doctrine/cache", + "version": "v1.7.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/cache.git", + "reference": "b3217d58609e9c8e661cd41357a54d926c4a2a1a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/cache/zipball/b3217d58609e9c8e661cd41357a54d926c4a2a1a", + "reference": "b3217d58609e9c8e661cd41357a54d926c4a2a1a", + "shasum": "" + }, + "require": { + "php": "~7.1" + }, + "conflict": { + "doctrine/common": ">2.2,<2.4" + }, + "require-dev": { + "alcaeus/mongo-php-adapter": "^1.1", + "mongodb/mongodb": "^1.1", + "phpunit/phpunit": "^5.7", + "predis/predis": "~1.0" + }, + "suggest": { + "alcaeus/mongo-php-adapter": "Required to use legacy MongoDB driver" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.7.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Caching library offering an object-oriented API for many cache backends", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "cache", + "caching" + ], + "time": "2017-08-25T07:02:50+00:00" + }, + { + "name": "doctrine/collections", + "version": "v1.5.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/collections.git", + "reference": "a01ee38fcd999f34d9bfbcee59dbda5105449cbf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/collections/zipball/a01ee38fcd999f34d9bfbcee59dbda5105449cbf", + "reference": "a01ee38fcd999f34d9bfbcee59dbda5105449cbf", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "doctrine/coding-standard": "~0.1@dev", + "phpunit/phpunit": "^5.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\Collections\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Collections Abstraction library", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "array", + "collections", + "iterator" + ], + "time": "2017-07-22T10:37:32+00:00" + }, + { + "name": "doctrine/common", + "version": "v2.8.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/common.git", + "reference": "f68c297ce6455e8fd794aa8ffaf9fa458f6ade66" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/common/zipball/f68c297ce6455e8fd794aa8ffaf9fa458f6ade66", + "reference": "f68c297ce6455e8fd794aa8ffaf9fa458f6ade66", + "shasum": "" + }, + "require": { + "doctrine/annotations": "1.*", + "doctrine/cache": "1.*", + "doctrine/collections": "1.*", + "doctrine/inflector": "1.*", + "doctrine/lexer": "1.*", + "php": "~7.1" + }, + "require-dev": { + "phpunit/phpunit": "^5.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.8.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\": "lib/Doctrine/Common" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Common Library for Doctrine projects", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "collections", + "eventmanager", + "persistence", + "spl" + ], + "time": "2017-08-31T08:43:38+00:00" + }, + { + "name": "doctrine/dbal", + "version": "v2.7.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/dbal.git", + "reference": "11037b4352c008373561dc6fc836834eed80c3b5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/11037b4352c008373561dc6fc836834eed80c3b5", + "reference": "11037b4352c008373561dc6fc836834eed80c3b5", + "shasum": "" + }, + "require": { + "doctrine/common": "^2.7.1", + "ext-pdo": "*", + "php": "^7.1" + }, + "require-dev": { + "doctrine/coding-standard": "^4.0", + "phpunit/phpunit": "^7.0", + "phpunit/phpunit-mock-objects": "!=3.2.4,!=3.2.5", + "symfony/console": "^2.0.5||^3.0", + "symfony/phpunit-bridge": "^3.4.5|^4.0.5" + }, + "suggest": { + "symfony/console": "For helpful console commands such as SQL execution and import of files." + }, + "bin": [ + "bin/doctrine-dbal" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\DBAL\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + } + ], + "description": "Database Abstraction Layer", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "database", + "dbal", + "persistence", + "queryobject" + ], + "time": "2018-04-07T18:44:18+00:00" + }, + { + "name": "doctrine/inflector", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/inflector.git", + "reference": "5527a48b7313d15261292c149e55e26eae771b0a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/5527a48b7313d15261292c149e55e26eae771b0a", + "reference": "5527a48b7313d15261292c149e55e26eae771b0a", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^6.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Inflector\\": "lib/Doctrine/Common/Inflector" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Common String Manipulations with regard to casing and singular/plural rules.", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "inflection", + "pluralize", + "singularize", + "string" + ], + "time": "2018-01-09T20:05:19+00:00" + }, + { + "name": "doctrine/lexer", + "version": "v1.0.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/lexer.git", + "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/83893c552fd2045dd78aef794c31e694c37c0b8c", + "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\Lexer\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "lexer", + "parser" + ], + "time": "2014-09-09T13:34:57+00:00" + }, { "name": "dragonmantank/cron-expression", "version": "v2.1.0", diff --git a/example/Worker.php b/example/Worker.php index 868ea32f..ee8e319a 100644 --- a/example/Worker.php +++ b/example/Worker.php @@ -1,7 +1,7 @@ _create(QueueInterface::class, $workerQueue); + assert(!$this->hasWorkerQueue(), new \LogicException('NeighborhoodsKojoExampleWorkerQueue is already set.')); + $this->NeighborhoodsKojoExampleWorkerQueue = $workerQueue; return $this; } - protected function _getWorkerQueue(): QueueInterface + protected function getWorkerQueue(): QueueInterface { - return $this->_read(QueueInterface::class); - } + assert($this->hasWorkerQueue(), new \LogicException('NeighborhoodsKojoExampleWorkerQueue is not set.')); - protected function _getWorkerQueueClone(): QueueInterface - { - return clone $this->_getWorkerQueue(); + return $this->NeighborhoodsKojoExampleWorkerQueue; } - protected function _hasWorkerQueue(): bool + protected function hasWorkerQueue(): bool { - return $this->_exists(QueueInterface::class); + return isset($this->NeighborhoodsKojoExampleWorkerQueue); } - protected function _unsetWorkerQueue(): self + protected function unsetWorkerQueue(): self { - $this->_delete(QueueInterface::class); + assert($this->hasWorkerQueue(), new \LogicException('NeighborhoodsKojoExampleWorkerQueue is not set.')); + unset($this->NeighborhoodsKojoExampleWorkerQueue); return $this; } -} \ No newline at end of file +} diff --git a/example/Worker/Queue/Message.php b/example/Worker/Queue/Message.php index 18959e95..20378efa 100644 --- a/example/Worker/Queue/Message.php +++ b/example/Worker/Queue/Message.php @@ -1,7 +1,7 @@ _read(MessageInterface::class); } - protected function _getWorkerQueueMessageClone(): MessageInterface - { - return clone $this->_getWorkerQueueMessage(); - } - - protected function _hasWorkerQueueMessage(): bool + protected function hasWorkerQueueMessage(): bool { return $this->_exists(MessageInterface::class); } - protected function _unsetWorkerQueueMessage(): self + protected function unsetWorkerQueueMessage(): self { $this->_delete(MessageInterface::class); return $this; } -} \ No newline at end of file +} diff --git a/example/Worker/Queue/Message/Factory.php b/example/Worker/Queue/Message/Factory.php index d5c8491e..cff8881f 100644 --- a/example/Worker/Queue/Message/Factory.php +++ b/example/Worker/Queue/Message/Factory.php @@ -1,18 +1,19 @@ _getWorkerQueueMessageClone(); - - return $workerQueueMessage; + return clone $this->getWorkerQueueMessage(); } -} \ No newline at end of file +} diff --git a/example/Worker/Queue/Message/FactoryInterface.php b/example/Worker/Queue/Message/FactoryInterface.php new file mode 100644 index 00000000..c7cd3d80 --- /dev/null +++ b/example/Worker/Queue/Message/FactoryInterface.php @@ -0,0 +1,12 @@ +_assertValidArrayItemType(parent::offsetGet($index)); } - /** @param \Neighborhoods\Kojo\Example\Worker\Queue\Message $workerQueueMessage */ + /** @param MessageInterface $workerQueueMessage */ public function offsetSet($index, $workerQueueMessage) { parent::offsetSet($index, $this->_assertValidArrayItemType($workerQueueMessage)); } - /** @param \Neighborhoods\Kojo\Example\Worker\Queue\Message $workerQueueMessage */ + /** @param MessageInterface $workerQueueMessage */ public function append($workerQueueMessage) { $this->_assertValidArrayItemType($workerQueueMessage); parent::append($workerQueueMessage); } - public function current(): \Neighborhoods\Kojo\Example\Worker\Queue\Message + public function current(): MessageInterface { return parent::current(); } - protected function _assertValidArrayItemType(\Neighborhoods\Kojo\Example\Worker\Queue\Message $workerQueueMessage) + protected function _assertValidArrayItemType(MessageInterface $workerQueueMessage) { return $workerQueueMessage; } - protected function _assertValidArrayType(\Neighborhoods\Kojo\Example\Worker\Queue\Message ...$workerQueueMessages - ): MessageArrayInterface{ + protected function _assertValidArrayType(MessageInterface ...$workerQueueMessages): MessageArrayInterface + { return $this; } -} \ No newline at end of file + + public function getArrayCopy(): MessageArrayInterface + { + return new self(parent::getArrayCopy(), (int)$this->getFlags()); + } +} diff --git a/example/Worker/Queue/MessageArrayInterface.php b/example/Worker/Queue/MessageArrayInterface.php new file mode 100644 index 00000000..cf69e1ec --- /dev/null +++ b/example/Worker/Queue/MessageArrayInterface.php @@ -0,0 +1,23 @@ +