Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix exception messages
  • Loading branch information
uwej711 committed Aug 31, 2012
1 parent ce4f404 commit 0027135
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
36 changes: 18 additions & 18 deletions lib/Doctrine/ODM/PHPCR/DocumentManager.php
Expand Up @@ -539,7 +539,7 @@ public function getDocumentsByQuery(QueryInterface $query, $className = null)
public function persist($document)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}

$this->errorIfClosed();
Expand All @@ -559,7 +559,7 @@ public function persist($document)
public function bindTranslation($document, $locale)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}

$this->errorIfClosed();
Expand All @@ -579,7 +579,7 @@ public function bindTranslation($document, $locale)
public function getLocalesFor($document)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}

$this->errorIfClosed();
Expand All @@ -600,7 +600,7 @@ public function getLocalesFor($document)
public function move($document, $targetPath)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}

$this->errorIfClosed();
Expand All @@ -622,7 +622,7 @@ public function move($document, $targetPath)
public function reorder($document, $srcName, $targetName, $before)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}

$this->errorIfClosed();
Expand All @@ -641,7 +641,7 @@ public function reorder($document, $srcName, $targetName, $before)
public function remove($document)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}

$this->errorIfClosed();
Expand All @@ -658,7 +658,7 @@ public function remove($document)
public function merge($document)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}

throw new \BadMethodCallException(__METHOD__.' not yet implemented');
Expand All @@ -680,7 +680,7 @@ public function merge($document)
public function detach($document)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}

$this->errorIfClosed();
Expand All @@ -696,7 +696,7 @@ public function detach($document)
public function refresh($document)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}

$this->errorIfClosed();
Expand All @@ -722,7 +722,7 @@ public function refresh($document)
public function getChildren($document, $filter = null, $fetchDepth = null)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}

$this->errorIfClosed();
Expand All @@ -743,7 +743,7 @@ public function getChildren($document, $filter = null, $fetchDepth = null)
public function getReferrers($document, $type = null, $name = null)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}

$this->errorIfClosed();
Expand All @@ -759,7 +759,7 @@ public function getReferrers($document, $type = null, $name = null)
public function flush($document = null)
{
if (null !== $document && !is_object($document) && !is_array($document)) {
throw new \InvalidArgumentException(gettype($document));
throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}

$this->errorIfClosed();
Expand Down Expand Up @@ -811,7 +811,7 @@ public function getReference($documentName, $id)
public function checkin($document)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}

$this->errorIfClosed();
Expand All @@ -826,7 +826,7 @@ public function checkin($document)
public function checkout($document)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}

$this->errorIfClosed();
Expand All @@ -845,7 +845,7 @@ public function checkout($document)
public function checkpoint($document)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}

$this->errorIfClosed();
Expand Down Expand Up @@ -905,7 +905,7 @@ public function removeVersion($documentVersion)
public function getAllLinearVersions($document, $limit = -1)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}

$this->errorIfClosed();
Expand Down Expand Up @@ -946,7 +946,7 @@ public function findVersionByName($className, $id, $versionName)
public function contains($document)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}

return $this->unitOfWork->contains($document);
Expand Down Expand Up @@ -1001,7 +1001,7 @@ public function close()
public function initializeObject($document)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
throw new \InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
}

$this->unitOfWork->initializeObject($document);
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/PHPCR/UnitOfWork.php
Expand Up @@ -650,7 +650,7 @@ public function scheduleReorder($document, $srcName, $targetName, $before)
unset($this->scheduledRemovals[$oid]);
break;
case self::STATE_DETACHED:
throw new \InvalidArgumentException('Detached document passed to move(): '.self::objToStr($document, $this->dm));
throw new \InvalidArgumentException('Detached document passed to reorder(): '.self::objToStr($document, $this->dm));
}

$this->scheduledReorders[$oid] = array($document, $srcName, $targetName, $before);
Expand Down Expand Up @@ -1667,7 +1667,7 @@ private function executeReorders($documents)
$dest = null;
$found = false;
foreach ($children as $name => $child) {
if ($name == $target) {
if ($name === $target) {
$found = true;
} elseif ($found) {
$dest = $name;
Expand Down
8 changes: 8 additions & 0 deletions tests/Doctrine/Tests/ODM/PHPCR/Functional/ReorderTest.php
Expand Up @@ -55,6 +55,14 @@ public function testReorder() {
$this->assertSame(array('second', 'first', 'third', 'fourth'), $this->getChildrenNames($parent->getChildren()));
}


public function testReorderNoObject() {
$this->setExpectedException('InvalidArgumentException');
$this->dm->reorder('parent', 'first', 'second', false);
$this->dm->flush();
}


public function testReorderBeforeFirst() {
$parent = $this->dm->find(null, $this->node->getPath());
$children = $parent->getChildren();
Expand Down

0 comments on commit 0027135

Please sign in to comment.