Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

exception refactoring to only use doctrine exceptions #322

Merged
merged 1 commit into from

3 participants

@dbu
Collaborator
dbu commented
Q A
Bug fix? yes
New feature? yes
BC breaks? yes
Deprecations? no
Tests pass? yes
Fixed tickets PHPCR-71
License MIT
Doc PR --

This is a minimal PR to not throw any \InvalidArgumentExceptions or \RuntimeException anymore but all based on PHPCRException or doctrine commons MappingException. What could still be done is moving exception messages into factory methods to clean up the code, but that will be no BC break (created http://www.doctrine-project.org/jira/browse/PHPCR-116)

@dbu dbu commented on the diff
lib/Doctrine/ODM/PHPCR/Mapping/MappingException.php
@@ -28,7 +30,7 @@
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Lukas Kahwe Smith <smith@pooteeweet.org>
*/
-class MappingException extends \Exception
+class MappingException extends BaseMappingException
@dbu Collaborator
dbu added a note

not 100% sure if this is what we should do - we can't extend PHPCRException at the same time. then again, mapping problems are in develepment or on the console so exception catching and handling is probably irrelevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@lsmith77 lsmith77 merged commit 49dca3c into master
@lsmith77 lsmith77 deleted the exception-cleanup branch
@lsmith77 lsmith77 referenced this pull request
Merged

[WIP] Query Builder V2 #318

8 of 8 tasks complete
@dantleech
Collaborator

Sorry to get to the party rather later, but would it not make sense to have the exceptions in Doctrine\ODM\PHPCR\Exception\{InvalidArgument,Runtime,}Exception ?

Seems this is what doctrine does: use Doctrine\Common\Proxy\Exception\InvalidArgumentException

@lsmith77
Owner

this was just a quick fix but not really a proper solution. ideally we should indeed use those exceptions along with maybe an interface to make it possible to catch all PHPCR ODM exception in one swoop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 2, 2013
  1. @dbu
This page is out of date. Refresh to see the latest.
Showing with 212 additions and 133 deletions.
  1. +2 −3 lib/Doctrine/ODM/PHPCR/DocumentClassMapper.php
  2. +1 −1  lib/Doctrine/ODM/PHPCR/DocumentClassMapperInterface.php
  3. +77 −33 lib/Doctrine/ODM/PHPCR/DocumentManager.php
  4. +3 −1 lib/Doctrine/ODM/PHPCR/Exception/CascadeException.php
  5. +3 −1 lib/Doctrine/ODM/PHPCR/Exception/MissingTranslationException.php
  6. +2 −1  lib/Doctrine/ODM/PHPCR/Id/AssignedIdGenerator.php
  7. +3 −1 lib/Doctrine/ODM/PHPCR/Id/IdException.php
  8. +2 −1  lib/Doctrine/ODM/PHPCR/Id/IdGenerator.php
  9. +3 −2 lib/Doctrine/ODM/PHPCR/Id/RepositoryIdGenerator.php
  10. +5 −5 lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadata.php
  11. +3 −16 lib/Doctrine/ODM/PHPCR/Mapping/MappingException.php
  12. +31 −0 lib/Doctrine/ODM/PHPCR/PHPCRInvalidArgumentException.php
  13. +1 −1  lib/Doctrine/ODM/PHPCR/Proxy/ProxyFactory.php
  14. +4 −4 lib/Doctrine/ODM/PHPCR/Query/PhpcrExpressionVisitor.php
  15. +1 −1  lib/Doctrine/ODM/PHPCR/Query/QueryBuilderException.php
  16. +3 −2 lib/Doctrine/ODM/PHPCR/Query/QueryException.php
  17. +1 −1  lib/Doctrine/ODM/PHPCR/ReferenceManyCollection.php
  18. +32 −26 lib/Doctrine/ODM/PHPCR/UnitOfWork.php
  19. +8 −7 tests/Doctrine/Tests/ODM/PHPCR/Functional/BasicCrudTest.php
  20. +4 −4 tests/Doctrine/Tests/ODM/PHPCR/Functional/DetachTest.php
  21. +1 −1  tests/Doctrine/Tests/ODM/PHPCR/Functional/FlushTest.php
  22. +2 −2 tests/Doctrine/Tests/ODM/PHPCR/Functional/MergeTest.php
  23. +1 −1  tests/Doctrine/Tests/ODM/PHPCR/Functional/RefreshTest.php
  24. +2 −2 tests/Doctrine/Tests/ODM/PHPCR/Functional/ReorderTest.php
  25. +6 −5 tests/Doctrine/Tests/ODM/PHPCR/Functional/Translation/DocumentManagerTest.php
  26. +2 −2 tests/Doctrine/Tests/ODM/PHPCR/Functional/Versioning/AnnotationsTest.php
  27. +4 −4 tests/Doctrine/Tests/ODM/PHPCR/Functional/Versioning/VersioningTest.php
  28. +1 −1  tests/Doctrine/Tests/ODM/PHPCR/Id/IdGeneratorTest.php
  29. +2 −2 tests/Doctrine/Tests/ODM/PHPCR/Query/PhpcrExpressionVisitorTest.php
  30. +2 −2 tests/Doctrine/Tests/ODM/PHPCR/Translation/LocaleChooserTest.php
View
5 lib/Doctrine/ODM/PHPCR/DocumentClassMapper.php
@@ -19,8 +19,6 @@
namespace Doctrine\ODM\PHPCR;
-use InvalidArgumentException;
-
use Doctrine\ODM\PHPCR\DocumentManager;
use PHPCR\NodeInterface;
@@ -78,7 +76,8 @@ public function validateClassName(DocumentManager $dm, $document, $className)
$class = $dm->getClassMetadata(get_class($document));
$path = $class->getIdentifierValue($document);
$msg = "Doctrine metadata mismatch! Requested type '$className' type does not match type '".get_class($document)."' stored in the metadata at path '$path'";
- throw new InvalidArgumentException($msg);
+
+ throw new PHPCRException($msg);
}
}
}
View
2  lib/Doctrine/ODM/PHPCR/DocumentClassMapperInterface.php
@@ -57,7 +57,7 @@ public function writeMetadata(DocumentManager $dm, NodeInterface $node, $classNa
* @param object $document
* @param string $className
*
- * @throws \InvalidArgumentException if document is not of type $className
+ * @throws PHPCRException if document is not of type $className
*/
public function validateClassName(DocumentManager $dm, $document, $className);
}
View
110 lib/Doctrine/ODM/PHPCR/DocumentManager.php
@@ -19,6 +19,7 @@
namespace Doctrine\ODM\PHPCR;
+use Doctrine\Common\Collections\Collection;
use Doctrine\ODM\PHPCR\Exception\MissingTranslationException;
use Doctrine\ODM\PHPCR\Mapping\ClassMetadataFactory;
use Doctrine\ODM\PHPCR\Proxy\ProxyFactory;
@@ -42,6 +43,7 @@
/**
* Document Manager
+ *
* @author Jordi Boggiano <j.boggiano@seld.be>
* @author Pascal Helfenstein <nicam@nicam.ch>
* @author Daniel Barsotti <daniel.barsotti@liip.ch>
@@ -144,12 +146,12 @@ public function setTranslationStrategy($key, TranslationStrategyInterface $strat
*
* @return Translation\TranslationStrategy\TranslationStrategyInterface
*
- * @throws \InvalidArgumentException if there is no strategy registered with the given key
+ * @throws PHPCRInvalidArgumentException if there is no strategy registered with the given key
*/
public function getTranslationStrategy($key)
{
if (!isset($this->translationStrategy[$key])) {
- throw new \InvalidArgumentException("You must set a valid translator strategy for a document that contains translatable fields ($key is not a valid strategy or was not previously registered)");
+ throw new PHPCRInvalidArgumentException("You must set a valid translator strategy for a document that contains translatable fields ($key is not a valid strategy or was not previously registered)");
}
return $this->translationStrategy[$key];
@@ -164,7 +166,7 @@ public function getTranslationStrategy($key)
public function getLocaleChooserStrategy()
{
if (!isset($this->localeChooserStrategy)) {
- throw new \InvalidArgumentException("You must configure a language chooser strategy when having documents with the translatable annotation");
+ throw new PHPCRInvalidArgumentException("You must configure a language chooser strategy when having documents with the translatable annotation");
}
return $this->localeChooserStrategy;
@@ -287,6 +289,9 @@ public function getClassMetadata($className)
* @param string $id the path or uuid of the document to find
*
* @return object|null the document if found, otherwise null
+ *
+ * @throws PHPCRException if $className is specified and does not match
+ * the class of the document that was found at $id.
*/
public function find($className, $id)
{
@@ -317,10 +322,13 @@ public function find($className, $id)
/**
* Finds many documents by id.
*
- * @param null|string $className
- * @param array $ids
+ * @param null|string $className Only return documents that match the
+ * specified class. All others are treated as not found.
+ * @param array $ids List of repository paths and/or uuids to
+ * find documents. Non-existing ids are ignored.
*
- * @return object
+ * @return Collection list of documents that where found with the $ids and
+ * if specified the $className.
*/
public function findMany($className, array $ids)
{
@@ -354,7 +362,7 @@ public function findMany($className, array $ids)
try {
$this->unitOfWork->validateClassName($document, $className);
$documents[$id] = $document;
- } catch (\InvalidArgumentException $e) {
+ } catch (PHPCRException $e) {
// ignore on class mismatch
}
} elseif (isset($nodes[$id])) {
@@ -387,6 +395,8 @@ public function findMany($className, array $ids)
*
* @return object the translated document.
*
+ * @throws PHPCRException if $className is specified and does not match
+ * the class of the document that was found at $id.
* @throws MissingTranslationException if $fallback is false and the
* translation was not found
*/
@@ -588,11 +598,13 @@ public function getDocumentsByPhpcrQuery(QueryInterface $query, $className = nul
* updated with the locale.
*
* @param object $document the document to persist
+ *
+ * @throws PHPCRInvalidArgumentException if $document is not an object.
*/
public function persist($document)
{
if (!is_object($document)) {
- throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
+ throw new PHPCRInvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}
$this->errorIfClosed();
@@ -607,12 +619,13 @@ public function persist($document)
* @param object $document the document to persist a translation of
* @param string $locale the locale this document currently has
*
+ * @throws PHPCRInvalidArgumentException if $document is not an object or not managed.
* @throws PHPCRException if the document is not translatable
*/
public function bindTranslation($document, $locale)
{
if (!is_object($document)) {
- throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
+ throw new PHPCRInvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}
$this->errorIfClosed();
@@ -624,11 +637,13 @@ public function bindTranslation($document, $locale)
*
* @param object $document the document to persist a translation of
* @param string $locale the locale this document currently has
+ *
+ * @throws PHPCRInvalidArgumentException if $document is not an object.
*/
public function removeTranslation($document, $locale)
{
if (!is_object($document)) {
- throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
+ throw new PHPCRInvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}
$this->errorIfClosed();
@@ -644,12 +659,13 @@ public function removeTranslation($document, $locale)
*
* @return array of strings with all locales existing for this particular document
*
- * @throws PHPCRException if the document is not translatable
+ * @throws PHPCRInvalidArgumentException if $document is not an object.
+ * @throws MissingTranslationException if the document is not translatable
*/
public function getLocalesFor($document, $includeFallbacks = false)
{
if (!is_object($document)) {
- throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
+ throw new PHPCRInvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}
$this->errorIfClosed();
@@ -695,11 +711,13 @@ public function isDocumentTranslatable($document)
*
* @param object $document an already registered document
* @param string $targetPath the target path including the nodename
+ *
+ * @throws PHPCRInvalidArgumentException if $document is not an object.
*/
public function move($document, $targetPath)
{
if (!is_object($document)) {
- throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
+ throw new PHPCRInvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}
if (strpos($targetPath, '/') !== 0) {
@@ -721,11 +739,13 @@ public function move($document, $targetPath)
* @param string $srcName the nodename of the child to be reordered
* @param string $targetName the nodename of the target of the reordering
* @param boolean $before whether to move before or after the target
+ *
+ * @throws PHPCRInvalidArgumentException if $document is not an object.
*/
public function reorder($document, $srcName, $targetName, $before)
{
if (!is_object($document)) {
- throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
+ throw new PHPCRInvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}
$this->errorIfClosed();
@@ -740,11 +760,13 @@ public function reorder($document, $srcName, $targetName, $before)
* that make the relationship explicit.
*
* @param object $document
+ *
+ * @throws PHPCRInvalidArgumentException if $document is not an object.
*/
public function remove($document)
{
if (!is_object($document)) {
- throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
+ throw new PHPCRInvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}
$this->errorIfClosed();
@@ -766,11 +788,13 @@ public function remove($document)
*
* @return object The managed document where $document has been merged
* into. This is *not* the same instance as the parameter.
+ *
+ * @throws PHPCRInvalidArgumentException if $document is not an object.
*/
public function merge($document)
{
if (!is_object($document)) {
- throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
+ throw new PHPCRInvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}
$this->errorIfClosed();
@@ -787,11 +811,13 @@ public function merge($document)
* reference it.
*
* @param object $document The object to detach.
+ *
+ * @throws PHPCRInvalidArgumentException if $document is not an object.
*/
public function detach($document)
{
if (!is_object($document)) {
- throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
+ throw new PHPCRInvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}
$this->errorIfClosed();
@@ -802,11 +828,13 @@ public function detach($document)
* Refresh the given document by querying the PHPCR to get the current state.
*
* @param object $document
+ *
+ * @throws PHPCRInvalidArgumentException if $document is not an object.
*/
public function refresh($document)
{
if (!is_object($document)) {
- throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
+ throw new PHPCRInvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}
$this->errorIfClosed();
@@ -827,11 +855,13 @@ public function refresh($document)
* @param string $locale the locale to use during the loading of this collection
*
* @return ChildrenCollection collection of child documents
+ *
+ * @throws PHPCRInvalidArgumentException if $document is not an object.
*/
public function getChildren($document, $filter = null, $fetchDepth = null, $locale = null)
{
if (!is_object($document)) {
- throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
+ throw new PHPCRInvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}
$this->errorIfClosed();
@@ -861,11 +891,13 @@ public function getChildren($document, $filter = null, $fetchDepth = null, $loca
instanceof.
*
* @return ReferrersCollection collection of referrer documents
+ *
+ * @throws PHPCRInvalidArgumentException if $document is not an object.
*/
public function getReferrers($document, $type = null, $name = null, $locale = null, $refClass = null)
{
if (!is_object($document)) {
- throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
+ throw new PHPCRInvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}
$this->errorIfClosed();
@@ -880,13 +912,13 @@ public function getReferrers($document, $type = null, $name = null, $locale = nu
* @param object|array|null $document optionally limit to a specific
* document or an array of documents
*
- * @throws \InvalidArgumentException if $document is neither null nor a
+ * @throws PHPCRInvalidArgumentException if $document is neither null nor a
* document or an array of documents
*/
public function flush($document = null)
{
if (null !== $document && !is_object($document) && !is_array($document)) {
- throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
+ throw new PHPCRInvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}
$this->errorIfClosed();
@@ -923,11 +955,13 @@ public function getReference($documentName, $id)
* @see checkpoint
*
* @param object $document
+ *
+ * @throws PHPCRInvalidArgumentException if $document is not an object.
*/
public function checkin($document)
{
if (!is_object($document)) {
- throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
+ throw new PHPCRInvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}
$this->errorIfClosed();
@@ -938,11 +972,13 @@ public function checkin($document)
* Make a checked in document writable again.
*
* @param object $document
+ *
+ * @throws PHPCRInvalidArgumentException if $document is not an object.
*/
public function checkout($document)
{
if (!is_object($document)) {
- throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
+ throw new PHPCRInvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}
$this->errorIfClosed();
@@ -955,11 +991,13 @@ public function checkout($document)
* A new version is created and the writable document stays in checked out state
*
* @param object $document The document
+ *
+ * @throws PHPCRInvalidArgumentException if $document is not an object.
*/
public function checkpoint($document)
{
if (!is_object($document)) {
- throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
+ throw new PHPCRInvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}
$this->errorIfClosed();
@@ -1013,11 +1051,13 @@ public function removeVersion($documentVersion)
*
* @return array of <versionname> => array("name" => <versionname>, "labels" => <array of labels>, "created" => <DateTime>)
* oldest version first
+ *
+ * @throws PHPCRInvalidArgumentException if $document is not an object.
*/
public function getAllLinearVersions($document, $limit = -1)
{
if (!is_object($document)) {
- throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
+ throw new PHPCRInvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}
$this->errorIfClosed();
@@ -1038,7 +1078,7 @@ public function getAllLinearVersions($document, $limit = -1)
*
* @return object the detached document or null if the document is not found
*
- * @throws \InvalidArgumentException if there is a document with $id but no
+ * @throws PHPCRInvalidArgumentException if there is a document with $id but no
* version with $name
* @throws \PHPCR\UnsupportedRepositoryOperationException if the implementation
* does not support versioning
@@ -1056,11 +1096,13 @@ public function findVersionByName($className, $id, $versionName)
* @param object $document
*
* @return boolean true if the repository contains the object, false otherwise
+ *
+ * @throws PHPCRInvalidArgumentException if $document is not an object.
*/
public function contains($document)
{
if (!is_object($document)) {
- throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
+ throw new PHPCRInvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}
return $this->unitOfWork->contains($document);
@@ -1090,7 +1132,7 @@ public function clear($className = null)
$this->unitOfWork->clear();
} else {
//TODO
- throw new PHPCRException("DocumentManager#clear(\$className) not yet implemented.");
+ throw new PHPCRException('DocumentManager#clear($className) not yet implemented.');
}
}
@@ -1111,11 +1153,13 @@ public function close()
* This method is a no-op for other objects
*
* @param object $document
+ *
+ * @throws PHPCRInvalidArgumentException if $document is not an object.
*/
public function initializeObject($document)
{
if (!is_object($document)) {
- throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
+ throw new PHPCRInvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}
$this->unitOfWork->initializeObject($document);
@@ -1128,13 +1172,13 @@ public function initializeObject($document)
*
* @return \PHPCR\NodeInterface
*
- * @throws \InvalidArgumentException if the document is not an object
- * @throws PHPCRException if the document is not managed
+ * @throws PHPCRInvalidArgumentException if $document is not an object.
+ * @throws PHPCRException if $document is not managed
*/
public function getNodeForDocument($document)
{
if (!is_object($document)) {
- throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
+ throw new PHPCRInvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}
$path = $this->unitOfWork->getDocumentId($document);
View
4 lib/Doctrine/ODM/PHPCR/Exception/CascadeException.php
@@ -19,6 +19,8 @@
namespace Doctrine\ODM\PHPCR\Exception;
+use Doctrine\ODM\PHPCR\PHPCRException;
+
/**
* Missing translation exception class
*
@@ -27,7 +29,7 @@
* @since 1.0
* @author Lukas Kahwe Smith <smith@pooteeweet.org>
*/
-class CascadeException extends \InvalidArgumentException
+class CascadeException extends PHPCRException
{
public static function newDocumentFound($documentString)
{
View
4 lib/Doctrine/ODM/PHPCR/Exception/MissingTranslationException.php
@@ -19,6 +19,8 @@
namespace Doctrine\ODM\PHPCR\Exception;
+use Doctrine\ODM\PHPCR\PHPCRException;
+
/**
* Missing translation exception class
*
@@ -27,6 +29,6 @@
* @since 1.0
* @author Lukas Kahwe Smith <smith@pooteeweet.org>
*/
-class MissingTranslationException extends \InvalidArgumentException
+class MissingTranslationException extends PHPCRException
{
}
View
3  lib/Doctrine/ODM/PHPCR/Id/AssignedIdGenerator.php
@@ -21,6 +21,7 @@
use Doctrine\ODM\PHPCR\DocumentManager;
use Doctrine\ODM\PHPCR\Mapping\ClassMetadata;
+use Doctrine\ODM\PHPCR\PHPCRException;
/**
* Generator to handle explicitly assigned repository paths.
@@ -36,7 +37,7 @@ public function generate($document, ClassMetadata $cm, DocumentManager $dm)
{
$id = $cm->getFieldValue($document, $cm->identifier);
if (!$id) {
- throw new \RuntimeException('ID could not be determined. Make sure the document has a property with Doctrine\ODM\PHPCR\Mapping\Annotations\Id annotation and that the property is set to the path where the document is to be stored.');
+ throw new PHPCRException('ID could not be determined. Make sure the document has a property with Doctrine\ODM\PHPCR\Mapping\Annotations\Id annotation and that the property is set to the path where the document is to be stored.');
}
return $id;
View
4 lib/Doctrine/ODM/PHPCR/Id/IdException.php
@@ -2,7 +2,9 @@
namespace Doctrine\ODM\PHPCR\Id;
-class IdException extends \RuntimeException
+use Doctrine\ODM\PHPCR\PHPCRException;
+
+class IdException extends PHPCRException
{
public static function noIdentificationParameters($document, $parent, $nodename)
{
View
3  lib/Doctrine/ODM/PHPCR/Id/IdGenerator.php
@@ -21,6 +21,7 @@
use Doctrine\ODM\PHPCR\DocumentManager;
use Doctrine\ODM\PHPCR\Mapping\ClassMetadata;
+use Doctrine\ODM\PHPCR\PHPCRInvalidArgumentException;
/**
* Used to abstract ID generation
@@ -54,7 +55,7 @@ public static function create($generatorType)
break;
default:
- throw new \InvalidArgumentException("ID Generator does not exist: $generatorType");
+ throw new PHPCRInvalidArgumentException("ID Generator does not exist: $generatorType");
}
return $instance;
View
5 lib/Doctrine/ODM/PHPCR/Id/RepositoryIdGenerator.php
@@ -21,6 +21,7 @@
use Doctrine\ODM\PHPCR\DocumentManager;
use Doctrine\ODM\PHPCR\Mapping\ClassMetadata;
+use Doctrine\ODM\PHPCR\PHPCRException;
class RepositoryIdGenerator extends IdGenerator
{
@@ -34,12 +35,12 @@ public function generate($document, ClassMetadata $cm, DocumentManager $dm, $par
{
$repository = $dm->getRepository($cm->name);
if (!($repository instanceof RepositoryIdInterface)) {
- throw new \RuntimeException("ID could not be determined. Make sure the that the Repository '".get_class($repository)."' implements RepositoryIdInterface");
+ throw new PHPCRException("ID could not be determined. Make sure the that the Repository '".get_class($repository)."' implements RepositoryIdInterface");
}
$id = $repository->generateId($document, $parent);
if (!$id) {
- throw new \RuntimeException("ID could not be determined. Repository was unable to generate an ID");
+ throw new PHPCRException("ID could not be determined. Repository was unable to generate an ID");
}
return $id;
View
10 lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadata.php
@@ -19,11 +19,11 @@
namespace Doctrine\ODM\PHPCR\Mapping;
+use Doctrine\ODM\PHPCR\Mapping\MappingException;
use Doctrine\ODM\PHPCR\Event;
use ReflectionProperty;
use ReflectionClass;
use PHPCR\PropertyType;
-use InvalidArgumentException;
use Doctrine\Common\Persistence\Mapping\ReflectionService;
use Doctrine\Common\Persistence\Mapping\ClassMetadata as ClassMetadataInterface;
use Doctrine\Common\ClassLoader;
@@ -506,7 +506,7 @@ public function setLifecycleCallbacks(array $callbacks)
public function setVersioned($versionable)
{
if ($versionable && !in_array($versionable, self::$validVersionableAnnotations)) {
- throw new \InvalidArgumentException("Invalid value in '{$this->name}' for the versionable annotation: '{$versionable}'");
+ throw new MappingException("Invalid value in '{$this->name}' for the versionable annotation: '{$versionable}'");
}
$this->versionable = $versionable;
}
@@ -847,11 +847,11 @@ public function validateClassMapping()
}
if(!empty($this->versionNameField) && !$this->versionable){
- throw new \InvalidArgumentException(sprintf("You cannot use the @VersionName annotation on the non-versionable document %s (field = %s)", $this->name, $this->versionNameField));
+ throw new MappingException(sprintf("You cannot use the @VersionName annotation on the non-versionable document %s (field = %s)", $this->name, $this->versionNameField));
}
if(!empty($this->versionCreatedField) && !$this->versionable){
- throw new \InvalidArgumentException(sprintf("You cannot use the @VersionCreated annotation on the non-versionable document %s (field = %s)", $this->name, $this->versionCreatedField));
+ throw new MappingException(sprintf("You cannot use the @VersionCreated annotation on the non-versionable document %s (field = %s)", $this->name, $this->versionCreatedField));
}
if (count($this->translatableFields)) {
@@ -1141,7 +1141,7 @@ public function getTypeOfField($fieldName)
public function getAssociationTargetClass($fieldName)
{
if (!in_array($fieldName, $this->referenceMappings)) {
- throw new InvalidArgumentException("Association name expected, '$fieldName' is not an association in '{$this->name}'.");
+ throw new MappingException("Association name expected, '$fieldName' is not an association in '{$this->name}'.");
}
return $this->mappings[$fieldName]['targetDocument'];
View
19 lib/Doctrine/ODM/PHPCR/Mapping/MappingException.php
@@ -19,6 +19,8 @@
namespace Doctrine\ODM\PHPCR\Mapping;
+use Doctrine\Common\Persistence\Mapping\MappingException as BaseMappingException;
+
/**
* Mapping exception class
*
@@ -28,7 +30,7 @@
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Lukas Kahwe Smith <smith@pooteeweet.org>
*/
-class MappingException extends \Exception
+class MappingException extends BaseMappingException
@dbu Collaborator
dbu added a note

not 100% sure if this is what we should do - we can't extend PHPCRException at the same time. then again, mapping problems are in develepment or on the console so exception catching and handling is probably irrelevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
{
public static function classNotFound($className)
{
@@ -73,21 +75,11 @@ public static function missingTypeDefinition($document, $fieldName)
return new self("Property '$fieldName' in '$document' must have a type attribute defined");
}
- public static function fileMappingDriversRequireConfiguredDirectoryPath($path)
- {
- return new self("File mapping drivers must have a valid directory path, however the given path '$path' seems to be incorrect!");
- }
-
public static function classNotMapped($className)
{
return new self("Class '$className' is not mapped to a document");
}
- public static function pathRequired()
- {
- return new self('Path is required');
- }
-
public static function noTypeSpecified()
{
return new self('No type specified');
@@ -118,11 +110,6 @@ public static function mappingNotFound($className, $fieldName)
return new self("No mapping found for field '$fieldName' in class '$className'.");
}
- public static function mappingFileNotFound($className, $filedName)
- {
- return new self("No mapping file '$filedName' found for class '$className'.");
- }
-
public static function identifierRequired($entityName)
{
if (false !== ($parent = get_parent_class($entityName))) {
View
31 lib/Doctrine/ODM/PHPCR/PHPCRInvalidArgumentException.php
@@ -0,0 +1,31 @@
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\ODM\PHPCR;
+
+/**
+ * InvalidArgumentException for the PHPCR-ODM
+ *
+ * @license http://www.opensource.org/licenses/MIT-license.php MIT license
+ * @link www.doctrine-project.com
+ * @since 1.0
+ */
+class PHPCRInvalidArgumentException extends PHPCRException
+{
+}
View
2  lib/Doctrine/ODM/PHPCR/Proxy/ProxyFactory.php
@@ -28,8 +28,8 @@
use Doctrine\Common\Proxy\ProxyDefinition;
use Doctrine\Common\Proxy\Proxy;
use Doctrine\Common\Proxy\Exception\UnexpectedValueException;
+use Doctrine\Common\Proxy\Exception\InvalidArgumentException;
use ReflectionProperty;
-use InvalidArgumentException;
/**
* This factory is used to create proxy objects for entities at runtime.
View
8 lib/Doctrine/ODM/PHPCR/Query/PhpcrExpressionVisitor.php
@@ -67,7 +67,7 @@ public function walkComparison(Comparison $comparison)
$qomOperator = QOMConstant::JCR_OPERATOR_LIKE;
break;
default:
- throw new \InvalidArgumentException("Unsupported operator $operator");
+ throw new QueryException("Unsupported operator $operator");
}
if ($comparison instanceof NodeLocalName) {
@@ -97,7 +97,7 @@ public function walkCompositeExpression(CompositeExpression $expr)
}
if (count($constraintList) < 2) {
- throw new \RuntimeException(sprintf(
+ throw new QueryException(sprintf(
'Composite "%s" must have at least two constraints! (%d given)',
$expr->getType(),
count($constraintList)
@@ -112,7 +112,7 @@ public function walkCompositeExpression(CompositeExpression $expr)
$method = 'orConstraint';
break;
default:
- throw new \RuntimeException("Unknown composite " . $expr->getType());
+ throw new QueryException("Unknown composite " . $expr->getType());
}
$firstConstraint = array_shift($constraintList);
@@ -197,7 +197,7 @@ public function dispatch(Expression $expr)
return $this->walkSameNode($expr);
default:
- throw new \RuntimeException("Unknown Expression " . get_class($expr));
+ throw new QueryException("Unknown Expression " . get_class($expr));
}
}
}
View
2  lib/Doctrine/ODM/PHPCR/Query/QueryBuilderException.php
@@ -2,7 +2,7 @@
namespace Doctrine\ODM\PHPCR\Query;
-class QueryBuilderException extends \Exception
+class QueryBuilderException extends QueryException
{
public static function unknownPart($part, $parts)
{
View
5 lib/Doctrine/ODM/PHPCR/Query/QueryException.php
@@ -1,11 +1,12 @@
<?php
namespace Doctrine\ODM\PHPCR\Query;
+use Doctrine\ODM\PHPCR\PHPCRException;
/**
- * @author Daniel Leech <daniel@dantleech.com>
+ * @author Daniel Leech <daniel@dantleech.com>
*/
-class QueryException extends \Exception
+class QueryException extends PHPCRException
{
public static function hydrationModeNotKnown($hydrationMode)
{
View
2  lib/Doctrine/ODM/PHPCR/ReferenceManyCollection.php
@@ -64,7 +64,7 @@ public function initialize()
foreach ($referencedNodes as $referencedNode) {
$proxy = $uow->getOrCreateProxyFromNode($referencedNode, $this->locale);
if (isset($targetDocument) && !$proxy instanceOf $this->targetDocument) {
- throw new \RuntimeException("Unexpected class for referenced document at '{$referencedNode->getPath()}'. Expected '{$this->targetDocument}' but got '".ClassUtils::getClass($proxy)."'.");
+ throw new PHPCRException("Unexpected class for referenced document at '{$referencedNode->getPath()}'. Expected '{$this->targetDocument}' but got '".ClassUtils::getClass($proxy)."'.");
}
$referencedDocs[] = $proxy;
$this->originalReferencePaths[] = $referencedNode->getPath();
View
58 lib/Doctrine/ODM/PHPCR/UnitOfWork.php
@@ -244,10 +244,14 @@ public function __construct(DocumentManager $dm)
}
/**
- * @param object $document
- * @param string $className
+ * Validate if a document is of the specified class, if the global setting
+ * to validate is activated.
*
- * @throws \InvalidArgumentException
+ * @param object $document
+ * @param string|null $className The class name $document must be
+ * instanceof. Pass empty to not validate anything.
+ *
+ * @throws PHPCRException
*/
public function validateClassName($document, $className)
{
@@ -272,6 +276,9 @@ public function validateClassName($document, $className)
* @param array $hints
*
* @return object
+ *
+ * @throws PHPCRException if $className was specified and does not match
+ * the class of the document corresponding to $node.
*/
public function getOrCreateDocument($className, NodeInterface $node, array &$hints = array())
{
@@ -364,7 +371,7 @@ public function getOrCreateDocument($className, NodeInterface $node, array &$hin
$referencedNode = $node->getProperty($mapping['property'])->getNode();
$proxy = $this->getOrCreateProxyFromNode($referencedNode, $locale);
if (isset($mapping['targetDocument']) && !$proxy instanceOf $mapping['targetDocument']) {
- throw new \RuntimeException("Unexpected class for referenced document at '{$referencedNode->getPath()}'. Expected '{$mapping['targetDocument']}' but got '".ClassUtils::getClass($proxy)."'.");
+ throw new PHPCRException("Unexpected class for referenced document at '{$referencedNode->getPath()}'. Expected '{$mapping['targetDocument']}' but got '".ClassUtils::getClass($proxy)."'.");
}
} catch (RepositoryException $e) {
if ($e instanceof ItemNotFoundException || isset($hints['ignoreHardReferenceNotFound'])) {
@@ -546,7 +553,7 @@ public function bindTranslation($document, $locale)
{
$state = $this->getDocumentState($document);
if ($state !== self::STATE_MANAGED) {
- throw new \InvalidArgumentException('Document has to be managed to be able to bind a translation '.self::objToStr($document, $this->dm));
+ throw new PHPCRInvalidArgumentException('Document has to be managed to be able to bind a translation '.self::objToStr($document, $this->dm));
}
$class = $this->dm->getClassMetadata(get_class($document));
@@ -588,7 +595,7 @@ private function doScheduleInsert($document, &$visited, $overrideIdGenerator = n
$class = $this->dm->getClassMetadata(get_class($document));
if ($class->isMappedSuperclass) {
- throw new \InvalidArgumentException('Cannot persist a mapped super class instance: '.$class->name);
+ throw new PHPCRInvalidArgumentException('Cannot persist a mapped super class instance: '.$class->name);
}
$this->cascadeScheduleParentInsert($class, $document, $visited);
@@ -606,7 +613,7 @@ private function doScheduleInsert($document, &$visited, $overrideIdGenerator = n
$this->setDocumentState($oid, self::STATE_MANAGED);
break;
case self::STATE_DETACHED:
- throw new \InvalidArgumentException('Detached document or new document with already existing id passed to persist(): '.self::objToStr($document, $this->dm));
+ throw new PHPCRInvalidArgumentException('Detached document or new document with already existing id passed to persist(): '.self::objToStr($document, $this->dm));
}
$this->cascadeScheduleInsert($class, $document, $visited);
@@ -725,7 +732,7 @@ public function scheduleMove($document, $targetPath)
unset($this->scheduledRemovals[$oid]);
break;
case self::STATE_DETACHED:
- throw new \InvalidArgumentException('Detached document passed to move(): '.self::objToStr($document, $this->dm));
+ throw new PHPCRInvalidArgumentException('Detached document passed to move(): '.self::objToStr($document, $this->dm));
}
$this->scheduledMoves[$oid] = array($document, $targetPath);
@@ -739,10 +746,9 @@ public function scheduleReorder($document, $srcName, $targetName, $before)
$state = $this->getDocumentState($document);
switch ($state) {
case self::STATE_REMOVED:
- throw new \InvalidArgumentException('Removed document passed to reorder(): '.self::objToStr($document, $this->dm));
- break;
+ throw new PHPCRInvalidArgumentException('Removed document passed to reorder(): '.self::objToStr($document, $this->dm));
case self::STATE_DETACHED:
- throw new \InvalidArgumentException('Detached document passed to reorder(): '.self::objToStr($document, $this->dm));
+ throw new PHPCRInvalidArgumentException('Detached document passed to reorder(): '.self::objToStr($document, $this->dm));
}
if (! isset($this->scheduledReorders[$oid])) {
@@ -775,7 +781,7 @@ private function doRemove($document, &$visited)
unset($this->scheduledReorders[$oid]);
break;
case self::STATE_DETACHED:
- throw new \InvalidArgumentException('Detached document passed to remove(): '.self::objToStr($document, $this->dm));
+ throw new PHPCRInvalidArgumentException('Detached document passed to remove(): '.self::objToStr($document, $this->dm));
}
$this->scheduledRemovals[$oid] = $document;
@@ -902,7 +908,7 @@ public function computeSingleDocumentChangeSet($document)
{
$state = $this->getDocumentState($document);
if ($state !== self::STATE_MANAGED) {
- throw new \InvalidArgumentException('Document has to be managed for single computation '.self::objToStr($document, $this->dm));
+ throw new PHPCRInvalidArgumentException('Document has to be managed for single computation '.self::objToStr($document, $this->dm));
}
foreach ($this->scheduledInserts as $insertedDocument) {
@@ -991,7 +997,7 @@ private function computeAssociationChanges($class, $oid, $isNew, $actualData, $a
$computeMethod = 'computeReferrerChanges';
break;
default:
- throw new \RuntimeException('Unsupported association type used: '.$assocType);
+ throw new PHPCRInvalidArgumentException('Unsupported association type used: '.$assocType);
}
foreach ($mappings as $fieldName) {
@@ -1274,7 +1280,7 @@ private function computeChildChanges($mapping, $child, $parentId, $nodename, $pa
$this->computeChangeSet($targetClass, $child);
break;
case self::STATE_DETACHED:
- throw new \InvalidArgumentException('A detached document was found through a child relationship during cascading a persist operation: '.self::objToStr($child, $this->dm));
+ throw new PHPCRInvalidArgumentException('A detached document was found through a child relationship during cascading a persist operation: '.self::objToStr($child, $this->dm));
default:
if (PathHelper::getParentPath($this->getDocumentId($child)) !== $parentId) {
throw PHPCRException::cannotMoveByAssignment(self::objToStr($child, $this->dm));
@@ -1304,7 +1310,7 @@ private function computeReferenceChanges($mapping, $reference)
$this->computeChangeSet($targetClass, $reference);
break;
case self::STATE_DETACHED:
- throw new \InvalidArgumentException('A detached document was found through a reference during cascading a persist operation: '.self::objToStr($reference, $this->dm));
+ throw new PHPCRInvalidArgumentException('A detached document was found through a reference during cascading a persist operation: '.self::objToStr($reference, $this->dm));
}
}
@@ -1328,7 +1334,7 @@ private function computeReferrerChanges($mapping, $referrer)
$this->computeChangeSet($targetClass, $referrer);
break;
case self::STATE_DETACHED:
- throw new \InvalidArgumentException('A detached document was found through a referrer during cascading a persist operation: '.self::objToStr($referrer, $this->dm));
+ throw new PHPCRInvalidArgumentException('A detached document was found through a referrer during cascading a persist operation: '.self::objToStr($referrer, $this->dm));
}
}
@@ -1375,7 +1381,7 @@ private function doRefresh($document, &$visited)
$visited[$oid] = true;
if ($this->getDocumentState($document) !== self::STATE_MANAGED) {
- throw new \InvalidArgumentException('Document has to be managed to be refreshed '.self::objToStr($document, $this->dm));
+ throw new PHPCRInvalidArgumentException('Document has to be managed to be refreshed '.self::objToStr($document, $this->dm));
}
$this->session->refresh(true);
@@ -1459,11 +1465,11 @@ private function doMerge($document, array &$visited, $prevManagedCopy = null, $a
if ($managedCopy) {
// We have the document in-memory already, just make sure its not removed.
if ($this->getDocumentState($managedCopy) == self::STATE_REMOVED) {
- throw new \InvalidArgumentException("Removed document detected during merge at '$id'. Cannot merge with a removed document.");
+ throw new PHPCRInvalidArgumentException("Removed document detected during merge at '$id'. Cannot merge with a removed document.");
}
if (ClassUtils::getClass($managedCopy) != ClassUtils::getClass($document)) {
- throw new \InvalidArgumentException('Can not merge documents of different classes.');
+ throw new PHPCRInvalidArgumentException('Can not merge documents of different classes.');
}
if ($this->getCurrentLocale($managedCopy, $class) !== $locale) {
@@ -1481,7 +1487,7 @@ private function doMerge($document, array &$visited, $prevManagedCopy = null, $a
// If the identifier is ASSIGNED, it is NEW, otherwise an error
// since the managed document was not found.
if ($class->idGenerator !== ClassMetadata::GENERATOR_TYPE_ASSIGNED) {
- throw new \InvalidArgumentException("Document not found in merge operation: $id");
+ throw new PHPCRInvalidArgumentException("Document not found in merge operation: $id");
}
$managedCopy = $class->newInstance();
@@ -2418,14 +2424,14 @@ public function findVersionByName($className, $id, $versionName)
// there is no document with $id
return null;
} catch (UnsupportedRepositoryOperationException $e) {
- throw new \InvalidArgumentException("Document with id $id is not versionable", $e->getCode(), $e);
+ throw new PHPCRInvalidArgumentException("Document with id $id is not versionable", $e->getCode(), $e);
}
try {
$version = $history->getVersion($versionName);
$node = $version->getFrozenNode();
} catch (RepositoryException $e) {
- throw new \InvalidArgumentException("No version $versionName on document $id", $e->getCode(), $e);
+ throw new PHPCRInvalidArgumentException("No version $versionName on document $id", $e->getCode(), $e);
}
$hints = array('versionName' => $versionName, 'ignoreHardReferenceNotFound' => true);
@@ -2498,7 +2504,7 @@ public function getAllLinearVersions($document, $limit = -1)
$metadata = $this->dm->getClassMetadata(get_class($document));
if (!$metadata->versionable) {
- throw new \InvalidArgumentException(sprintf("The document of type '%s' is not versionable", $metadata->getName()));
+ throw new PHPCRInvalidArgumentException(sprintf("The document of type '%s' is not versionable", $metadata->getName()));
}
$versions = $this->session
@@ -2915,7 +2921,7 @@ public function removeTranslation($document, $locale)
}
if (1 === count($this->getLocalesFor($document))) {
- throw new \RuntimeException('The last translation of a translatable document may not be removed');
+ throw new PHPCRException('The last translation of a translatable document may not be removed');
}
if ($document instanceof Proxy) {
@@ -3043,7 +3049,7 @@ private function getFullVersionedNodePath($document)
$path = $this->getDocumentId($document);
$metadata = $this->dm->getClassMetadata(get_class($document));
if ($metadata->versionable !== 'full') {
- throw new \InvalidArgumentException(sprintf("The document at '%s' is not full versionable", $path));
+ throw new PHPCRInvalidArgumentException(sprintf("The document at '%s' is not full versionable", $path));
}
$node = $this->session->getNode($path);
View
15 tests/Doctrine/Tests/ODM/PHPCR/Functional/BasicCrudTest.php
@@ -2,12 +2,13 @@
namespace Doctrine\Tests\ODM\PHPCR\Functional;
-use Doctrine\ODM\PHPCR\Id\RepositoryIdInterface,
- Doctrine\ODM\PHPCR\DocumentRepository,
- Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM;
-
+use Doctrine\ODM\PHPCR\Id\RepositoryIdInterface;
+use Doctrine\ODM\PHPCR\DocumentRepository;
+use Doctrine\ODM\PHPCR\PHPCRInvalidArgumentException;
use PHPCR\PropertyType;
+use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM;
+
/**
* @group functional
*/
@@ -81,7 +82,7 @@ public function testInsert()
}
/**
- * @expectedException \InvalidArgumentException
+ * @expectedException \Doctrine\ODM\PHPCR\PHPCRInvalidArgumentException
*/
public function testInsertTwice()
{
@@ -267,7 +268,7 @@ public function testRemoveAndReinsert()
}
/**
- * @expectedException \InvalidArgumentException
+ * @expectedException \Doctrine\ODM\PHPCR\PHPCRInvalidArgumentException
*/
public function testRemoveAndInsertBeforeFlush()
{
@@ -382,7 +383,7 @@ public function testFindTypeValidation()
$this->assertNotInstanceOf($this->type, $user);
$this->dm->getConfiguration()->setValidateDoctrineMetadata(true);
- $this->setExpectedException('InvalidArgumentException');
+ $this->setExpectedException('\Doctrine\ODM\PHPCR\PHPCRException');
$this->dm->find($this->type, '/functional/user');
}
View
8 tests/Doctrine/Tests/ODM/PHPCR/Functional/DetachTest.php
@@ -52,7 +52,7 @@ public function testDetachNewObject()
}
/**
- * @expectedException \InvalidArgumentException
+ * @expectedException \Doctrine\ODM\PHPCR\PHPCRInvalidArgumentException
*/
public function testDetachedKnownObject()
{
@@ -81,7 +81,7 @@ public function testDetach()
}
/**
- * @expectedException \InvalidArgumentException
+ * @expectedException \Doctrine\ODM\PHPCR\PHPCRInvalidArgumentException
*/
public function testDetachWithPerist()
{
@@ -93,7 +93,7 @@ public function testDetachWithPerist()
}
/**
- * @expectedException \InvalidArgumentException
+ * @expectedException \Doctrine\ODM\PHPCR\PHPCRInvalidArgumentException
*/
public function testDetachWithMove()
{
@@ -105,7 +105,7 @@ public function testDetachWithMove()
}
/**
- * @expectedException \InvalidArgumentException
+ * @expectedException \Doctrine\ODM\PHPCR\PHPCRInvalidArgumentException
*/
public function testDetachWithRemove()
{
View
2  tests/Doctrine/Tests/ODM/PHPCR/Functional/FlushTest.php
@@ -168,7 +168,7 @@ public function testFlushSingleUnmanagedDocument()
$user->username = 'domnikl';
$user->status = 'developer';
- $this->setExpectedException('InvalidArgumentException');
+ $this->setExpectedException('\Doctrine\ODM\PHPCR\PHPCRInvalidArgumentException');
$this->dm->flush($user);
}
View
4 tests/Doctrine/Tests/ODM/PHPCR/Functional/MergeTest.php
@@ -78,7 +78,7 @@ public function testMergeRemovedDocument()
$this->dm->remove($user);
- $this->setExpectedException('InvalidArgumentException', "Removed document detected during merge at '/functional/beberlei'. Cannot merge with a removed document.");
+ $this->setExpectedException('\Doctrine\ODM\PHPCR\PHPCRInvalidArgumentException', "Removed document detected during merge at '/functional/beberlei'. Cannot merge with a removed document.");
$this->dm->merge($user);
}
@@ -104,7 +104,7 @@ public function testMergeWithManagedDocument()
}
/**
- * @expectedException \InvalidArgumentException
+ * @expectedException \Doctrine\ODM\PHPCR\PHPCRInvalidArgumentException
*/
public function testMergeChangeDocumentClass()
{
View
2  tests/Doctrine/Tests/ODM/PHPCR/Functional/RefreshTest.php
@@ -63,7 +63,7 @@ public function testRefreshResetsCollection()
}
/**
- * @expectedException \InvalidArgumentException
+ * @expectedException \Doctrine\ODM\PHPCR\PHPCRInvalidArgumentException
*/
public function testRefreshDetached()
{
View
4 tests/Doctrine/Tests/ODM/PHPCR/Functional/ReorderTest.php
@@ -102,7 +102,7 @@ public function testReorderNoop()
public function testReorderNoObject()
{
- $this->setExpectedException('InvalidArgumentException');
+ $this->setExpectedException('\Doctrine\ODM\PHPCR\PHPCRInvalidArgumentException');
$this->dm->reorder('parent', 'first', 'second', false);
$this->dm->flush();
}
@@ -180,7 +180,7 @@ public function testRemoveAfterReorder()
}
/**
- * @expectedException \InvalidArgumentException
+ * @expectedException \Doctrine\ODM\PHPCR\PHPCRInvalidArgumentException
*/
public function testReorderAfterRemove()
{
View
11 tests/Doctrine/Tests/ODM/PHPCR/Functional/Translation/DocumentManagerTest.php
@@ -2,6 +2,7 @@
namespace Doctrine\Tests\ODM\PHPCR\Functional\Translation;
+use Doctrine\ODM\PHPCR\PHPCRException;
use Doctrine\Tests\Models\Translation\Article;
use Doctrine\Tests\Models\Translation\Comment;
use Doctrine\Tests\Models\Translation\InvalidMapping;
@@ -34,7 +35,7 @@ class DocumentManagerTest extends PHPCRFunctionalTestCase
protected $node;
/**
- * @var \Doctrine\ODM\PHPCR\Mapping\ClassMetadata
+ * @var ClassMetadata
*/
protected $metadata;
@@ -166,7 +167,7 @@ public function testRemoveTranslation()
try {
$this->dm->removeTranslation($this->doc, 'fr');
$this->fail('Last translation should not be removable');
- } catch (\RuntimeException $e) {
+ } catch (PHPCRException $e) {
}
}
@@ -438,7 +439,7 @@ public function testFindTranslationWithLanguageFallback()
}
/**
- * @expectedException \InvalidArgumentException
+ * @expectedException \Doctrine\ODM\PHPCR\Exception\MissingTranslationException
*/
public function testFindTranslationWithInvalidLanguageFallback()
{
@@ -619,7 +620,7 @@ public function testRemove()
}
/**
- * @expectedException \InvalidArgumentException
+ * @expectedException \Doctrine\ODM\PHPCR\PHPCRInvalidArgumentException
*/
public function testInvalidTranslationStrategy()
{
@@ -634,7 +635,7 @@ public function testInvalidTranslationStrategy()
/**
* bindTranslation with a document that is not persisted should fail
*
- * @expectedException \InvalidArgumentException
+ * @expectedException \Doctrine\ODM\PHPCR\PHPCRInvalidArgumentException
*/
public function testBindTranslationWithoutPersist()
{
View
4 tests/Doctrine/Tests/ODM/PHPCR/Functional/Versioning/AnnotationsTest.php
@@ -44,7 +44,7 @@ public function testLoadAnnotations()
/**
* Test that using an invalid versionable annotation will not work
- * @expectedException \InvalidArgumentException
+ * @expectedException \Doctrine\ODM\PHPCR\Mapping\MappingException
*/
public function testLoadInvalidAnnotation()
{
@@ -54,7 +54,7 @@ public function testLoadInvalidAnnotation()
/**
* Test that using the Version annotation on non-versionable documents will not work
- * @expectedException \InvalidArgumentException
+ * @expectedException \Doctrine\ODM\PHPCR\Mapping\MappingException
*/
public function testLoadInconsistentAnnotations()
{
View
8 tests/Doctrine/Tests/ODM/PHPCR/Functional/Versioning/VersioningTest.php
@@ -141,7 +141,7 @@ public function testGetAllLinearVersions()
/**
* Test it's not possible to get a version of a non-versionable document
- * @expectedException \InvalidArgumentException
+ * @expectedException \Doctrine\ODM\PHPCR\PHPCRInvalidArgumentException
*/
public function testFindVersionByNameNotVersionable()
{
@@ -154,7 +154,7 @@ public function testFindVersionByNameNotVersionable()
/**
* Test that trying to read a non existing version fails
- * @expectedException \InvalidArgumentException
+ * @expectedException \Doctrine\ODM\PHPCR\PHPCRInvalidArgumentException
*/
public function testFindVersionByNameVersionDoesNotExist()
{
@@ -202,7 +202,7 @@ public function testFindVersionByNameWithReference()
}
/**
- * @expectedException \InvalidArgumentException
+ * @expectedException \Doctrine\ODM\PHPCR\PHPCRInvalidArgumentException
*/
public function testPersistVersionError()
{
@@ -303,7 +303,7 @@ public function testRemoveVersion()
/**
* Check the version we removed in testRemoveVersion does not exist anymore
* @depends testRemoveVersion
- * @expectedException \InvalidArgumentException
+ * @expectedException \Doctrine\ODM\PHPCR\PHPCRInvalidArgumentException
*/
public function testDeletedVersionDoesNotExistAnymore($lastVersionName)
{
View
2  tests/Doctrine/Tests/ODM/PHPCR/Id/IdGeneratorTest.php
@@ -33,7 +33,7 @@ public function testCreateGeneratorTypeParent()
}
/**
- * @expectedException \InvalidArgumentException
+ * @expectedException \Doctrine\ODM\PHPCR\PHPCRInvalidArgumentException
* @covers Doctrine\ODM\PHPCR\Id\IdGenerator::create
*/
public function testCreateException()
View
4 tests/Doctrine/Tests/ODM/PHPCR/Query/PhpcrExpressionVisitorTest.php
@@ -55,7 +55,7 @@ public function testWalkComparison($field, $exprMethod, $value, $expectedJcrOper
}
/**
- * @expectedException \InvalidArgumentException
+ * @expectedException \Doctrine\ODM\PHPCR\Query\QueryException
*/
public function testWalkComparison_unknownOperator()
{
@@ -112,7 +112,7 @@ public function getDispatchExpressions()
)
),
array(
- $eb->textSearch('foobar', 'barfoo'),
+ $eb->textSearch('foobar', 'barfoo'),
'PHPCR\Query\QOM\FullTextSearchInterface', array(
'getPropertyName' => 'foobar',
'getFullTextSearchExpression' => 'barfoo',
View
4 tests/Doctrine/Tests/ODM/PHPCR/Translation/LocaleChooserTest.php
@@ -36,7 +36,7 @@ public function testGetPreferredLocalesOrder()
}
/**
- * @expectedException InvalidArgumentException
+ * @expectedException \Doctrine\ODM\PHPCR\Exception\MissingTranslationException
*/
public function testGetPreferredLocalesOrderNonexisting()
{
@@ -60,7 +60,7 @@ public function testGetLocale()
}
/**
- * @expectedException InvalidArgumentException
+ * @expectedException \Doctrine\ODM\PHPCR\Exception\MissingTranslationException
*/
public function testSetLocaleNonexisting()
{
Something went wrong with that request. Please try again.