From 22c2fc81f63050ad23f7b0c40e430ff026e1e767 Mon Sep 17 00:00:00 2001 From: Jonathan Hawk Date: Sun, 28 Jan 2018 19:11:09 -0500 Subject: [PATCH] New 3.0.x; removing HHVM support; minimum PHP 7.1 --- .gitignore | 1 - .hhconfig | 0 .travis.yml | 16 +-- README.md | 12 +- build-mongodb.sh | 12 -- composer.json | 14 +- docs/01-exceptions.md | 28 ++++ docs/02-daos.md | 88 ++++++++++++ docs/03-events.md | 49 +++++++ docs/index.md | 9 ++ hhi/Dao.hhi | 13 -- hhi/Doctrine2.hhi | 31 ---- hhi/Event.hhi | 19 --- hhi/Event/PostDelete.hhi | 7 - hhi/Event/PostInsert.hhi | 7 - hhi/Event/PostUpdate.hhi | 7 - hhi/Event/PreDelete.hhi | 7 - hhi/Event/PreInsert.hhi | 7 - hhi/Event/PreUpdate.hhi | 7 - hhi/Event/Publishing.hhi | 32 ----- hhi/Exception.hhi | 8 -- hhi/Exception/Conflicting.hhi | 7 - hhi/Exception/Duplicative.hhi | 7 - hhi/Exception/Generic.hhi | 7 - hhi/Exception/Inoperable.hhi | 7 - hhi/Exception/Locked.hhi | 7 - hhi/Exception/Permanent.hhi | 7 - hhi/Exception/Transient.hhi | 7 - hhi/Exception/Translator/Doctrine.hhi | 11 -- hhi/Exception/Translator/MongoDb.hhi | 11 -- hhi/Exception/Unreachable.hhi | 7 - hhi/Exception/Unretrievable.hhi | 7 - hhi/Exception/Violating.hhi | 7 - hhi/MongoDb.hhi | 23 --- nbproject/licenseheader.txt | 18 --- nbproject/project.properties | 7 - nbproject/project.xml | 9 -- src/Dao.php | 10 +- src/Doctrine2.php | 13 +- src/Event.php | 8 +- src/Event/PostDelete.php | 8 +- src/Event/PostInsert.php | 8 +- src/Event/PostUpdate.php | 8 +- src/Event/PreDelete.php | 8 +- src/Event/PreInsert.php | 8 +- src/Event/PreUpdate.php | 8 +- src/Event/Publishing.php | 8 +- src/Exception.php | 8 +- src/Exception/Conflicting.php | 8 +- src/Exception/Duplicative.php | 8 +- src/Exception/Generic.php | 8 +- src/Exception/Inoperable.php | 8 +- src/Exception/Locked.php | 8 +- src/Exception/Permanent.php | 8 +- src/Exception/Transient.php | 8 +- src/Exception/Translator/Doctrine.php | 17 ++- src/Exception/Translator/MongoDb.php | 8 +- src/Exception/Unreachable.php | 8 +- src/Exception/Unretrievable.php | 8 +- src/Exception/Violating.php | 8 +- src/MongoDb.php | 8 +- tests/Doctrine2Test.php | 22 +-- tests/Event/PostDeleteTest.php | 6 +- tests/Event/PostInsertTest.php | 6 +- tests/Event/PostUpdate.php | 6 +- tests/Event/PreDeleteTest.php | 6 +- tests/Event/PreInsertTest.php | 6 +- tests/Event/PreUpdateTest.php | 6 +- tests/Event/PublisherTest.php | 6 +- tests/Exception/Translator/DoctrineTest.php | 151 ++++++++++++++++++++ tests/Exception/Translator/MongoDbTest.php | 6 +- tests/MongoDbTest.php | 6 +- travis-php.ini | 8 -- 73 files changed, 483 insertions(+), 483 deletions(-) delete mode 100644 .hhconfig delete mode 100755 build-mongodb.sh create mode 100644 docs/01-exceptions.md create mode 100644 docs/02-daos.md create mode 100644 docs/03-events.md create mode 100644 docs/index.md delete mode 100644 hhi/Dao.hhi delete mode 100644 hhi/Doctrine2.hhi delete mode 100644 hhi/Event.hhi delete mode 100644 hhi/Event/PostDelete.hhi delete mode 100644 hhi/Event/PostInsert.hhi delete mode 100644 hhi/Event/PostUpdate.hhi delete mode 100644 hhi/Event/PreDelete.hhi delete mode 100644 hhi/Event/PreInsert.hhi delete mode 100644 hhi/Event/PreUpdate.hhi delete mode 100644 hhi/Event/Publishing.hhi delete mode 100644 hhi/Exception.hhi delete mode 100644 hhi/Exception/Conflicting.hhi delete mode 100644 hhi/Exception/Duplicative.hhi delete mode 100644 hhi/Exception/Generic.hhi delete mode 100644 hhi/Exception/Inoperable.hhi delete mode 100644 hhi/Exception/Locked.hhi delete mode 100644 hhi/Exception/Permanent.hhi delete mode 100644 hhi/Exception/Transient.hhi delete mode 100644 hhi/Exception/Translator/Doctrine.hhi delete mode 100644 hhi/Exception/Translator/MongoDb.hhi delete mode 100644 hhi/Exception/Unreachable.hhi delete mode 100644 hhi/Exception/Unretrievable.hhi delete mode 100644 hhi/Exception/Violating.hhi delete mode 100644 hhi/MongoDb.hhi delete mode 100644 nbproject/licenseheader.txt delete mode 100644 nbproject/project.properties delete mode 100644 nbproject/project.xml create mode 100644 tests/Exception/Translator/DoctrineTest.php diff --git a/.gitignore b/.gitignore index d793572..6695378 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -/nbproject/private/ /vendor/ /build/ /composer.lock diff --git a/.hhconfig b/.hhconfig deleted file mode 100644 index e69de29..0000000 diff --git a/.travis.yml b/.travis.yml index 61cec5b..0e12c41 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,24 +1,22 @@ sudo: required dist: trusty +services: + - mongodb language: php php: - - 7 - - hhvm -matrix: - allow_failures: - - php: hhvm + - 7.1 + - 7.2 before_install: - composer self-update install: - composer update --ignore-platform-reqs --prefer-source before_script: - - if [[ $TRAVIS_PHP_VERSION != "hhvm" ]]; then phpenv config-add travis-php.ini; fi - - if [[ $TRAVIS_PHP_VERSION = "hhvm" ]]; then sudo cat travis-php.ini >> /etc/hhvm/php.ini; ./build-mongodb.sh; fi + - phpenv config-add travis-php.ini script: - vendor/bin/phpunit --coverage-clover=coverage.clover after_script: - - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi;' - - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi;' + - wget https://scrutinizer-ci.com/ocular.phar + - php ocular.phar code-coverage:upload --format=php-clover coverage.clover cache: directories: - $HOME/.composer/cache diff --git a/README.md b/README.md index 715659c..81f7141 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,7 @@ This is its Data Access Object support component. You can use these classes to s [![Build Status](https://travis-ci.org/libreworks/caridea-dao.svg)](https://travis-ci.org/libreworks/caridea-dao) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/libreworks/caridea-dao/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/libreworks/caridea-dao/?branch=master) [![Code Coverage](https://scrutinizer-ci.com/g/libreworks/caridea-dao/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/libreworks/caridea-dao/?branch=master) - -We've also included `.hhi` files for the Hack typechecker. +[![Documentation Status](http://readthedocs.org/projects/caridea-dao/badge/?version=latest)](http://caridea-dao.readthedocs.io/en/latest/?badge=latest) ## Installation @@ -20,7 +19,8 @@ You can install this library using Composer: $ composer require caridea/dao ``` -* The master branch (version 2.x) of this project requires PHP 7.0 and depends on `caridea/event`. +* The master branch (version 3.x) of this project requires PHP 7.1 and depends on `caridea/event`. +* Version 2.x of this project requires PHP 7.0 and depends on `caridea/event`. ## Compliance @@ -28,6 +28,10 @@ Releases of this library will conform to [Semantic Versioning](http://semver.org Our code is intended to comply with [PSR-1](http://www.php-fig.org/psr/psr-1/), [PSR-2](http://www.php-fig.org/psr/psr-2/), and [PSR-4](http://www.php-fig.org/psr/psr-4/). If you find any issues related to standards compliance, please send a pull request! +## Documentation + +* Head over to [Read the Docs](http://caridea-dao.readthedocs.io/en/latest/) + ## Features We provide a mechanism to translate vendor-specific exceptions (right now, MongoDB and Doctrine exceptions) into a standard exception hierarchy. @@ -56,4 +60,4 @@ class MyDao extends \Caridea\Dao\MongoDb }); } } -``` \ No newline at end of file +``` diff --git a/build-mongodb.sh b/build-mongodb.sh deleted file mode 100755 index 16f9ae4..0000000 --- a/build-mongodb.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -mkdir -p /tmp/builds/hippo -sudo apt-get install -y --no-install-recommends libtool make wget hhvm-dev libdouble-conversion-dev liblz4-dev -cd /tmp/builds/hippo -wget -O /tmp/builds/hippo/mongo.tgz https://github.com/mongodb/mongo-hhvm-driver/releases/download/1.1.3/hhvm-mongodb-1.1.3.tgz -tar -xzf mongo.tgz -cd hhvm-mongodb-1.1.3 -hphpize -cmake . -make configlib -make -j $(nproc --all) -sudo make install diff --git a/composer.json b/composer.json index 96631f7..e99dc23 100644 --- a/composer.json +++ b/composer.json @@ -13,22 +13,22 @@ ], "extra": { "branch-alias": { - "dev-master": "2.1.x-dev" + "dev-master": "3.0.x-dev" } }, "require": { - "php": ">=7.0.0", + "php": ">=7.1.0", "psr/log": "^1.0", - "caridea/event": "^2.1" + "caridea/event": "^3.0" }, "require-dev": { - "phpunit/phpunit": "^5.2.0", - "libreworks/psr3-log-hhi": "^1.0.0", - "libreworks/ext-mongodb-hhi": "^1.1.0", - "mongodb/mongodb": "1.1.x-dev" + "phpunit/phpunit": "^6.0.0", + "doctrine/orm": "^2.0.0", + "mongodb/mongodb": "^1.2.0" }, "suggest": { "ext-mongodb": "Allows use of MongoDB DAO", + "doctrine/orm": "Allows use of Doctrine2 DAO", "mongodb/mongodb": "In case you want to make life easier for yourself" }, "autoload": { diff --git a/docs/01-exceptions.md b/docs/01-exceptions.md new file mode 100644 index 0000000..26e3bf5 --- /dev/null +++ b/docs/01-exceptions.md @@ -0,0 +1,28 @@ +# Exception Hierarchy + +We provide a mechanism to translate vendor-specific exceptions into a standard exception hierarchy. + +## Reason + +It's all about separation of concerns and abstraction. Using the translation utilities in this library, you can wrap vendor-specific exceptions in these generic exceptions. + +It decouples your persistence layer from the rest of your application. You can swap out the library you use to store data and not have to worry about changes in the rest of your application. + +## Exception Classes + +All of the following classes are in the `Caridea\Dao\Exception` namespace: + +* `Inoperable` – An exception for invalid API usage and configuration problems (extends from `\LogicException`) +* `Transient` – An abstract super class for problems that might not occur a second time (extends from `\RuntimeException`) + * `Conflicting` – An exception for concurrency failures + * `Unreachable` – An exception for connection problems +* `Permanent` – An abstract super class for problems that will probably occur a second time (extends from `\RuntimeException`) + * `Generic` – An exception for any other problem not covered elsewhere + * `Locked` – An exception for unwritable records + * `Unretrievable` – An exception for unexpected results, for instance no results or too many results + * `Violating` – An exception for constraint violations + * `Duplicative` – An exception for unique constraint violations + +## Translators + +We distribute two translation utilities with this library: one for the popular [Doctrine ORM library](http://www.doctrine-project.org/), the other for the popular [MongoDB library](https://github.com/mongodb/mongo-php-library). diff --git a/docs/02-daos.md b/docs/02-daos.md new file mode 100644 index 0000000..2876bb2 --- /dev/null +++ b/docs/02-daos.md @@ -0,0 +1,88 @@ +# Abstract DAO Classes + +This library comes with two super-classes to be extended by your own projects: + +* `Caridea\Dao\Doctrine2` – designed for the popular [Doctrine ORM library](http://www.doctrine-project.org/) +* `Caridea\Dao\MongoDb` – designed for the popular [MongoDB library](https://github.com/mongodb/mongo-php-library) + +They both extend from `Caridea\Dao\Dao`, which is an abstract class that implements `Psr\Log\LoggerAwareInterface`. + +## Doctrine + +The Doctrine DAO constructor takes the `Doctrine\ORM\EntityManager`, the name of the entity, and an optional `Psr\Log\LoggerInterface`. Once created, the following protected properties are available to subclasses: + +* `$manager` – The `EntityManager` you provided +* `$entityName` – The `string` entity name you provided +* `$repository` – A `Doctrine\ORM\EntityRepository` retrieved from the `EntityManager` +* `$logger` – A `Psr\Log\LoggerInterface`, guaranteed to be non-null + +There are also two very useful protected methods available to subclasses. + +### The doExecute Method + +The `doExecute` method accepts a `Closure` that gets passed the `EntityManager`. + +If an exception occurs while your function is being executed, it's translated and wrapped by one of the exceptions included in this library. + +```php +class MyDao extends \Caridea\Dao\Doctrine2 +{ + public function create($record) + { + $this->logger->info("Creating the record"); + $this->doExecute(function ($manager) use ($record) { + $manager->persist($record); + $manager->flush(); + }); + } +} +``` + +### The doExecuteInRepository Method + +Similarly, the `doExecuteInRepository` method accepts a `Closure` that gets passed the `EntityRepository`. + +If an exception occurs while your function is being executed, it's translated and wrapped by one of the exceptions included in this library. + +```php +class MyDao extends \Caridea\Dao\Doctrine2 +{ + public function find($id) + { + return $this->doExecuteInRepository(function ($repository) { + return $repository->find($id); + }); + } +} +``` + +## MongoDB + +The MongoDB DAO constructor takes the `MongoDB\Driver\Manager`, the name of the collection, and an optional `Psr\Log\LoggerInterface`. Once created, the following protected properties are available to subclasses: + +* `$manager` – The `Manager` you provided +* `$collection` – The `string` collection name you provided +* `$logger` – A `Psr\Log\LoggerInterface`, guaranteed to be non-null + +There are also a very useful protected method available to subclasses. + +### The doExecute Method + +The `doExecute` method accepts a `Closure` that gets passed the `Manager` and collection name. + +If an exception occurs while your function is being executed, it's translated and wrapped by one of the exceptions included in this library. + +```php +class MyDao extends \Caridea\Dao\MongoDb +{ + public function create($record) + { + $this->logger->info("Creating the record"); + $this->doExecute(function ($manager, $collection) use ($record) { + $bulk = new \MongoDB\Driver\BulkWrite(); + $bulk->insert($record); + return $manager->executeBulkWrite($collection, $bulk); + }); + } +} +``` diff --git a/docs/03-events.md b/docs/03-events.md new file mode 100644 index 0000000..f34d860 --- /dev/null +++ b/docs/03-events.md @@ -0,0 +1,49 @@ +# Events + +This library includes several events that can be broadcast, and a trait you can use in your DAOs to broadcast these events. + +## Event Classes + +The following classes are all in the `Caridea\Dao\Event` namespace. They all extend from the `Caridea\Dao\Event` class, which includes a method: `getEntity` that returns the entity involved. + +* `PreDelete` – To be broadcast before a delete event +* `PostDelete` – To be broadcast after a delete event +* `PreInsert` – To be broadcast before an insert event +* `PostInsert` – To be broadcast after an insert event +* `PreUpdate` – To be broadcast before an update event +* `PostUpdate` – To be broadcast after an update event + +## Publishing Trait + +The `Caridea\Dao\Event\Publishing` trait has methods your DAO can call that publish the above events. They all accept a single argument that is the entity involved. + +* `preDelete` – publishes a `PreDelete` event +* `postDelete` – publishes a `PostDelete` event +* `preInsert` – publishes a `PreInsert` event +* `postInsert` – publishes a `PostInsert` event +* `preUpdate` – publishes a `PreUpdate` event +* `postUpdate` – publishes a `PostUpdate` event + +Here's an example class that uses this trait: + +```php +class MyDao extends \Caridea\Dao\MongoDb implements \Caridea\Event\PublisherAware +{ + use \Caridea\Dao\Event\Publishing; + + public function create($record) + { + $this->preInsert($record); + $this->doExecute(function () { + // do some persistence magic + }); + $this->postInsert($record); + } +} +``` + +When creating an instance of this class, you'd want to make sure to call `setPublisher`, or better yet, use [caridea/container](https://github.com/libreworks/caridea-container) to factory your DAO. + +## But My Persistence Library Has Events… + +Awesome! Don't use this trait, then! If your library (e.g. Doctrine) already handles events that occur to entities, then this trait becomes irrelevant. diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..7adf781 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,9 @@ +# caridea/dao + +🍤 Caridea is a miniscule PHP application library. This shrimpy fellow is what you'd use when you just want some helping hands and not a full-blown framework. + +This is its Data Access Object support library. You can use these classes to support DAOs that you write. + +* [Exception Hierarchy](01-exceptions.md) +* [Abstract DAO Classes](02-daos.md) +* [Events](03-events.md) diff --git a/hhi/Dao.hhi b/hhi/Dao.hhi deleted file mode 100644 index 0cc7203..0000000 --- a/hhi/Dao.hhi +++ /dev/null @@ -1,13 +0,0 @@ -logger = $logger ?? new \Psr\Log\NullLogger(); - } -} diff --git a/hhi/Doctrine2.hhi b/hhi/Doctrine2.hhi deleted file mode 100644 index f9a14dd..0000000 --- a/hhi/Doctrine2.hhi +++ /dev/null @@ -1,31 +0,0 @@ -manager = $manager; - $this->entityName = $entityName; - $this->repository = $manager->getRepository($entityName); - } - - protected function doExecute((function(EntityManager): Ta) $cb): Ta - { - return $cb($this->manager); - } - - protected function doExecuteInRepository((function(EntityRepository): Ta) $cb): Ta - { - return $cb($this->repository); - } -} diff --git a/hhi/Event.hhi b/hhi/Event.hhi deleted file mode 100644 index bc908b6..0000000 --- a/hhi/Event.hhi +++ /dev/null @@ -1,19 +0,0 @@ - extends \Caridea\Event\Event -{ - private To $entity; - - public function __construct(Ts $source, To $entity) - { - parent::__construct($source); - $this->entity = $entity; - } - - public function getEntity(): To - { - return $this->entity; - } -} diff --git a/hhi/Event/PostDelete.hhi b/hhi/Event/PostDelete.hhi deleted file mode 100644 index a887531..0000000 --- a/hhi/Event/PostDelete.hhi +++ /dev/null @@ -1,7 +0,0 @@ - extends \Caridea\Dao\Event -{ -} diff --git a/hhi/Event/PostInsert.hhi b/hhi/Event/PostInsert.hhi deleted file mode 100644 index ae0dd7d..0000000 --- a/hhi/Event/PostInsert.hhi +++ /dev/null @@ -1,7 +0,0 @@ - extends \Caridea\Dao\Event -{ -} diff --git a/hhi/Event/PostUpdate.hhi b/hhi/Event/PostUpdate.hhi deleted file mode 100644 index 11c2b28..0000000 --- a/hhi/Event/PostUpdate.hhi +++ /dev/null @@ -1,7 +0,0 @@ - extends \Caridea\Dao\Event -{ -} diff --git a/hhi/Event/PreDelete.hhi b/hhi/Event/PreDelete.hhi deleted file mode 100644 index 5752458..0000000 --- a/hhi/Event/PreDelete.hhi +++ /dev/null @@ -1,7 +0,0 @@ - extends \Caridea\Dao\Event -{ -} diff --git a/hhi/Event/PreInsert.hhi b/hhi/Event/PreInsert.hhi deleted file mode 100644 index e5b3c7e..0000000 --- a/hhi/Event/PreInsert.hhi +++ /dev/null @@ -1,7 +0,0 @@ - extends \Caridea\Dao\Event -{ -} diff --git a/hhi/Event/PreUpdate.hhi b/hhi/Event/PreUpdate.hhi deleted file mode 100644 index 9a85684..0000000 --- a/hhi/Event/PreUpdate.hhi +++ /dev/null @@ -1,7 +0,0 @@ - extends \Caridea\Dao\Event -{ -} diff --git a/hhi/Event/Publishing.hhi b/hhi/Event/Publishing.hhi deleted file mode 100644 index c2b11d5..0000000 --- a/hhi/Event/Publishing.hhi +++ /dev/null @@ -1,32 +0,0 @@ -(T $entity): void - { - } - - protected function postDelete(T $entity): void - { - } - - protected function preInsert(T $entity): void - { - } - - protected function postInsert(T $entity): void - { - } - - protected function preUpdate(T $entity): void - { - } - - protected function postUpdate(T $entity): void - { - } -} diff --git a/hhi/Exception.hhi b/hhi/Exception.hhi deleted file mode 100644 index 288badc..0000000 --- a/hhi/Exception.hhi +++ /dev/null @@ -1,8 +0,0 @@ -manager = $manager; - $this->collection = $collection; - } - - protected function doExecute((function(Manager, string): Ta) $cb): Ta - { - return $cb($this->manager, $this->collection); - } -} diff --git a/nbproject/licenseheader.txt b/nbproject/licenseheader.txt deleted file mode 100644 index 9181613..0000000 --- a/nbproject/licenseheader.txt +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Caridea - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - * - * @copyright 2015 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License - */ diff --git a/nbproject/project.properties b/nbproject/project.properties deleted file mode 100644 index 76f6f91..0000000 --- a/nbproject/project.properties +++ /dev/null @@ -1,7 +0,0 @@ -include.path=${php.global.include.path} -php.version=PHP_56 -source.encoding=UTF-8 -src.dir=. -tags.asp=false -tags.short=false -web.root=. diff --git a/nbproject/project.xml b/nbproject/project.xml deleted file mode 100644 index 267f301..0000000 --- a/nbproject/project.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - org.netbeans.modules.php.project - - - caridea-dao - - - diff --git a/src/Dao.php b/src/Dao.php index e26ffcc..6e0b73d 100644 --- a/src/Dao.php +++ b/src/Dao.php @@ -15,18 +15,18 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao; /** * An abstract Data Access Object. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ -abstract class Dao +abstract class Dao implements \Psr\Log\LoggerAwareInterface { use \Psr\Log\LoggerAwareTrait; diff --git a/src/Doctrine2.php b/src/Doctrine2.php index a747927..0818ba3 100644 --- a/src/Doctrine2.php +++ b/src/Doctrine2.php @@ -15,20 +15,18 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao; use Doctrine\ORM\EntityManager; /** - * An abstract Data Access Object for MongoDb. + * An abstract Data Access Object for the Doctrine ORM library. * - * Requires the `mongodb` extension. - * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ abstract class Doctrine2 extends Dao { @@ -41,7 +39,6 @@ abstract class Doctrine2 extends Dao */ protected $entityName; /** - * * @var \Doctrine\ORM\EntityRepository The entity repository */ protected $repository; diff --git a/src/Event.php b/src/Event.php index 64e87ea..40bac07 100644 --- a/src/Event.php +++ b/src/Event.php @@ -15,16 +15,16 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao; /** * An abstract peristence event. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ abstract class Event extends \Caridea\Event\Event { diff --git a/src/Event/PostDelete.php b/src/Event/PostDelete.php index 06a7678..2c308f8 100644 --- a/src/Event/PostDelete.php +++ b/src/Event/PostDelete.php @@ -15,16 +15,16 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao\Event; /** * Delete event. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ class PostDelete extends \Caridea\Dao\Event { diff --git a/src/Event/PostInsert.php b/src/Event/PostInsert.php index 46105ff..267e6f8 100644 --- a/src/Event/PostInsert.php +++ b/src/Event/PostInsert.php @@ -15,16 +15,16 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao\Event; /** * Insert event. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ class PostInsert extends \Caridea\Dao\Event { diff --git a/src/Event/PostUpdate.php b/src/Event/PostUpdate.php index 15de90d..9439a71 100644 --- a/src/Event/PostUpdate.php +++ b/src/Event/PostUpdate.php @@ -15,16 +15,16 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao\Event; /** * Update event. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ class PostUpdate extends \Caridea\Dao\Event { diff --git a/src/Event/PreDelete.php b/src/Event/PreDelete.php index 465aabf..4ca5fde 100644 --- a/src/Event/PreDelete.php +++ b/src/Event/PreDelete.php @@ -15,16 +15,16 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao\Event; /** * Delete event. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ class PreDelete extends \Caridea\Dao\Event { diff --git a/src/Event/PreInsert.php b/src/Event/PreInsert.php index d1eb44e..b53b459 100644 --- a/src/Event/PreInsert.php +++ b/src/Event/PreInsert.php @@ -15,16 +15,16 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao\Event; /** * Insert event. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ class PreInsert extends \Caridea\Dao\Event { diff --git a/src/Event/PreUpdate.php b/src/Event/PreUpdate.php index 391d1cb..59d52fc 100644 --- a/src/Event/PreUpdate.php +++ b/src/Event/PreUpdate.php @@ -15,16 +15,16 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao\Event; /** * Update event. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ class PreUpdate extends \Caridea\Dao\Event { diff --git a/src/Event/Publishing.php b/src/Event/Publishing.php index 0154cf9..99ef006 100644 --- a/src/Event/Publishing.php +++ b/src/Event/Publishing.php @@ -15,8 +15,8 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao\Event; @@ -26,8 +26,8 @@ * We don't build this into the DAO itself because your persistence layer may * implement an event system. Duplicity is bad! * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ trait Publishing { diff --git a/src/Exception.php b/src/Exception.php index 012089c..1fd9edb 100644 --- a/src/Exception.php +++ b/src/Exception.php @@ -15,16 +15,16 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao; /** * Tagging interface for DAO exceptions. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ interface Exception { diff --git a/src/Exception/Conflicting.php b/src/Exception/Conflicting.php index 1e773ff..822da47 100644 --- a/src/Exception/Conflicting.php +++ b/src/Exception/Conflicting.php @@ -15,16 +15,16 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao\Exception; /** * Exception for concurrency problems (e.g. failed optimistic or pessimistic lock) * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ class Conflicting extends Transient { diff --git a/src/Exception/Duplicative.php b/src/Exception/Duplicative.php index 55515cd..109d55e 100644 --- a/src/Exception/Duplicative.php +++ b/src/Exception/Duplicative.php @@ -15,16 +15,16 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao\Exception; /** * An exception thrown when an insert or update would violate a unique constraint. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ class Duplicative extends Violating { diff --git a/src/Exception/Generic.php b/src/Exception/Generic.php index 7882092..eaf8f50 100644 --- a/src/Exception/Generic.php +++ b/src/Exception/Generic.php @@ -15,16 +15,16 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao\Exception; /** * An uncategorized persistence exception. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ class Generic extends Permanent { diff --git a/src/Exception/Inoperable.php b/src/Exception/Inoperable.php index 6c9f8ea..a6fe582 100644 --- a/src/Exception/Inoperable.php +++ b/src/Exception/Inoperable.php @@ -15,16 +15,16 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao\Exception; /** * Exception for invalid usage of an API (e.g. trying to rewind cursors that can't be) * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ class Inoperable extends \LogicException implements \Caridea\Dao\Exception { diff --git a/src/Exception/Locked.php b/src/Exception/Locked.php index 28859ba..e50a5c4 100644 --- a/src/Exception/Locked.php +++ b/src/Exception/Locked.php @@ -15,8 +15,8 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao\Exception; @@ -30,8 +30,8 @@ * Updates to records that are actually *locked* using pessimistic locking * should instead use the `Conflicting` exception. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ class Locked extends Permanent { diff --git a/src/Exception/Permanent.php b/src/Exception/Permanent.php index d88917f..615d4f9 100644 --- a/src/Exception/Permanent.php +++ b/src/Exception/Permanent.php @@ -15,16 +15,16 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao\Exception; /** * The base class for permanent problems with Data access * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ abstract class Permanent extends \RuntimeException implements \Caridea\Dao\Exception { diff --git a/src/Exception/Transient.php b/src/Exception/Transient.php index 53a1b47..63468c0 100644 --- a/src/Exception/Transient.php +++ b/src/Exception/Transient.php @@ -15,16 +15,16 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao\Exception; /** * The base class for transient problems with Data access * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ abstract class Transient extends \RuntimeException implements \Caridea\Dao\Exception { diff --git a/src/Exception/Translator/Doctrine.php b/src/Exception/Translator/Doctrine.php index adfe672..671afd2 100644 --- a/src/Exception/Translator/Doctrine.php +++ b/src/Exception/Translator/Doctrine.php @@ -15,16 +15,16 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao\Exception\Translator; /** * Translates Doctrine ORM and ODM exceptions * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ class Doctrine { @@ -36,7 +36,9 @@ class Doctrine */ public static function translate(\Exception $e): \Exception { - if ($e instanceof \Doctrine\ORM\EntityNotFoundException || + if ($e instanceof \Doctrine\DBAL\Exception\ConnectionException) { + return new \Caridea\Dao\Exception\Unreachable("System unreachable or connection timed out", $e->getCode(), $e); + } elseif ($e instanceof \Doctrine\ORM\EntityNotFoundException || $e instanceof \Doctrine\ORM\UnexpectedResultException || $e instanceof \Doctrine\ODM\MongoDB\DocumentNotFoundException || $e instanceof \Doctrine\ODM\CouchDB\DocumentNotFoundException) { @@ -45,8 +47,13 @@ public static function translate(\Exception $e): \Exception $e instanceof \Doctrine\ORM\OptimisticLockException || $e instanceof \Doctrine\ODM\CouchDB\OptimisticLockException) { return new \Caridea\Dao\Exception\Conflicting("Optimistic or pessimistic concurrency failure", 409, $e); + } elseif ($e instanceof \Doctrine\DBAL\Exception\UniqueConstraintViolationException) { + return new \Caridea\Dao\Exception\Duplicative("Unique constraint violation", 409, $e); + } elseif ($e instanceof \Doctrine\DBAL\Exception\ConstraintViolationException) { + return new \Caridea\Dao\Exception\Violating("Constraint violation", 422, $e); } elseif ($e instanceof \Doctrine\ORM\Query\QueryException || $e instanceof \Doctrine\ORM\Mapping\MappingException || + $e instanceof \Doctrine\DBAL\Exception\SyntaxErrorException || $e instanceof \Doctrine\Common\Persistence\Mapping\MappingException) { return new \Caridea\Dao\Exception\Inoperable("Invalid API usage", 0, $e); } diff --git a/src/Exception/Translator/MongoDb.php b/src/Exception/Translator/MongoDb.php index d880126..de01b3d 100644 --- a/src/Exception/Translator/MongoDb.php +++ b/src/Exception/Translator/MongoDb.php @@ -15,16 +15,16 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao\Exception\Translator; /** * Translates MongoDB driver exceptions * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ class MongoDb { diff --git a/src/Exception/Unreachable.php b/src/Exception/Unreachable.php index d78d9de..378061e 100644 --- a/src/Exception/Unreachable.php +++ b/src/Exception/Unreachable.php @@ -15,16 +15,16 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao\Exception; /** * An exception thrown when a system cannot be reached (e.g. connection timeout) * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ class Unreachable extends Transient { diff --git a/src/Exception/Unretrievable.php b/src/Exception/Unretrievable.php index 2015088..8bacbf6 100644 --- a/src/Exception/Unretrievable.php +++ b/src/Exception/Unretrievable.php @@ -15,16 +15,16 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao\Exception; /** * When a record or records cannot be retrieved, for example empty results. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ class Unretrievable extends Permanent { diff --git a/src/Exception/Violating.php b/src/Exception/Violating.php index dc75a0c..4a87501 100644 --- a/src/Exception/Violating.php +++ b/src/Exception/Violating.php @@ -15,16 +15,16 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao\Exception; /** * An exception thrown when an insert or update would violate a constraint. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ class Violating extends Permanent { diff --git a/src/MongoDb.php b/src/MongoDb.php index fd058f1..0f8a2e2 100644 --- a/src/MongoDb.php +++ b/src/MongoDb.php @@ -15,8 +15,8 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao; @@ -27,8 +27,8 @@ * * Requires the `mongodb` extension. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ abstract class MongoDb extends Dao { diff --git a/tests/Doctrine2Test.php b/tests/Doctrine2Test.php index 09c88de..bfb65d4 100644 --- a/tests/Doctrine2Test.php +++ b/tests/Doctrine2Test.php @@ -14,15 +14,15 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao; /** * Generated by hand */ -class Doctrine2Test extends \PHPUnit_Framework_TestCase +class Doctrine2Test extends \PHPUnit\Framework\TestCase { /** * @covers \Caridea\Dao\Dao::__construct @@ -134,19 +134,3 @@ public function testExceptionRepo() }); } } - -namespace Doctrine\ORM; - -if (!class_exists('Doctrine\ORM\EntityManager')) { - class EntityManager - { - public function getRepository($name) - { - } - } -} -if (!class_exists('Doctrine\ORM\EntityRepository')) { - class EntityRepository - { - } -} diff --git a/tests/Event/PostDeleteTest.php b/tests/Event/PostDeleteTest.php index f3265c9..94a2047 100644 --- a/tests/Event/PostDeleteTest.php +++ b/tests/Event/PostDeleteTest.php @@ -14,15 +14,15 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao\Event; /** * Generated by hand */ -class PostDeleteTest extends \PHPUnit_Framework_TestCase +class PostDeleteTest extends \PHPUnit\Framework\TestCase { /** * @covers \Caridea\Dao\Event\PostDelete diff --git a/tests/Event/PostInsertTest.php b/tests/Event/PostInsertTest.php index 6a56c19..8bc5259 100644 --- a/tests/Event/PostInsertTest.php +++ b/tests/Event/PostInsertTest.php @@ -14,15 +14,15 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao\Event; /** * Generated by hand */ -class PostInsertTest extends \PHPUnit_Framework_TestCase +class PostInsertTest extends \PHPUnit\Framework\TestCase { /** * @covers \Caridea\Dao\Event\PostInsert diff --git a/tests/Event/PostUpdate.php b/tests/Event/PostUpdate.php index 93f1362..3342bd8 100644 --- a/tests/Event/PostUpdate.php +++ b/tests/Event/PostUpdate.php @@ -14,15 +14,15 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao\Event; /** * Generated by hand */ -class PostUpdateTest extends \PHPUnit_Framework_TestCase +class PostUpdateTest extends \PHPUnit\Framework\TestCase { /** * @covers \Caridea\Dao\Event\PostUpdate diff --git a/tests/Event/PreDeleteTest.php b/tests/Event/PreDeleteTest.php index 190889e..2605ef9 100644 --- a/tests/Event/PreDeleteTest.php +++ b/tests/Event/PreDeleteTest.php @@ -14,15 +14,15 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao\Event; /** * Generated by hand */ -class PreDeleteTest extends \PHPUnit_Framework_TestCase +class PreDeleteTest extends \PHPUnit\Framework\TestCase { /** * @covers \Caridea\Dao\Event\PreDelete diff --git a/tests/Event/PreInsertTest.php b/tests/Event/PreInsertTest.php index 765c13c..e128328 100644 --- a/tests/Event/PreInsertTest.php +++ b/tests/Event/PreInsertTest.php @@ -14,15 +14,15 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao\Event; /** * Generated by hand */ -class PreInsertTest extends \PHPUnit_Framework_TestCase +class PreInsertTest extends \PHPUnit\Framework\TestCase { /** * @covers \Caridea\Dao\Event\PreInsert diff --git a/tests/Event/PreUpdateTest.php b/tests/Event/PreUpdateTest.php index 3f7acf4..e265db8 100644 --- a/tests/Event/PreUpdateTest.php +++ b/tests/Event/PreUpdateTest.php @@ -14,15 +14,15 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao\Event; /** * Generated by hand */ -class PreUpdateTest extends \PHPUnit_Framework_TestCase +class PreUpdateTest extends \PHPUnit\Framework\TestCase { /** * @covers \Caridea\Dao\Event\PreUpdate diff --git a/tests/Event/PublisherTest.php b/tests/Event/PublisherTest.php index 2fe3125..a5865c1 100644 --- a/tests/Event/PublisherTest.php +++ b/tests/Event/PublisherTest.php @@ -14,15 +14,15 @@ * License for the specific language governing permissions and limitations under * the License. * - * @copyright 2015-2016 LibreWorks contributors - * @license http://opensource.org/licenses/Apache-2.0 Apache 2.0 License + * @copyright 2015-2018 LibreWorks contributors + * @license Apache-2.0 */ namespace Caridea\Dao\Event; /** * Generated by hand */ -class PublishingTest extends \PHPUnit_Framework_TestCase +class PublishingTest extends \PHPUnit\Framework\TestCase { use Publishing; diff --git a/tests/Exception/Translator/DoctrineTest.php b/tests/Exception/Translator/DoctrineTest.php new file mode 100644 index 0000000..d3428b2 --- /dev/null +++ b/tests/Exception/Translator/DoctrineTest.php @@ -0,0 +1,151 @@ +