* add phpunit as a dev dependency
* add some basic tests for UrlHelper::rewrite_relative() * fix UrlHelper::rewrite_relative() to work better on non-absolute relative URL paths
This commit is contained in:
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Prophecy.
|
||||
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
* Marcello Duarte <marcello.duarte@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Prophecy\Exception\Call;
|
||||
|
||||
use Prophecy\Exception\Prophecy\ObjectProphecyException;
|
||||
use Prophecy\Prophecy\ObjectProphecy;
|
||||
|
||||
class UnexpectedCallException extends ObjectProphecyException
|
||||
{
|
||||
private $methodName;
|
||||
private $arguments;
|
||||
|
||||
public function __construct($message, ObjectProphecy $objectProphecy,
|
||||
$methodName, array $arguments)
|
||||
{
|
||||
parent::__construct($message, $objectProphecy);
|
||||
|
||||
$this->methodName = $methodName;
|
||||
$this->arguments = $arguments;
|
||||
}
|
||||
|
||||
public function getMethodName()
|
||||
{
|
||||
return $this->methodName;
|
||||
}
|
||||
|
||||
public function getArguments()
|
||||
{
|
||||
return $this->arguments;
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Prophecy.
|
||||
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
* Marcello Duarte <marcello.duarte@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Prophecy\Exception\Doubler;
|
||||
|
||||
use Prophecy\Doubler\Generator\Node\ClassNode;
|
||||
|
||||
class ClassCreatorException extends \RuntimeException implements DoublerException
|
||||
{
|
||||
private $node;
|
||||
|
||||
public function __construct($message, ClassNode $node)
|
||||
{
|
||||
parent::__construct($message);
|
||||
|
||||
$this->node = $node;
|
||||
}
|
||||
|
||||
public function getClassNode()
|
||||
{
|
||||
return $this->node;
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Prophecy.
|
||||
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
* Marcello Duarte <marcello.duarte@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Prophecy\Exception\Doubler;
|
||||
|
||||
use ReflectionClass;
|
||||
|
||||
class ClassMirrorException extends \RuntimeException implements DoublerException
|
||||
{
|
||||
private $class;
|
||||
|
||||
public function __construct($message, ReflectionClass $class)
|
||||
{
|
||||
parent::__construct($message);
|
||||
|
||||
$this->class = $class;
|
||||
}
|
||||
|
||||
public function getReflectedClass()
|
||||
{
|
||||
return $this->class;
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Prophecy.
|
||||
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
* Marcello Duarte <marcello.duarte@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Prophecy\Exception\Doubler;
|
||||
|
||||
class ClassNotFoundException extends DoubleException
|
||||
{
|
||||
private $classname;
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
* @param string $classname
|
||||
*/
|
||||
public function __construct($message, $classname)
|
||||
{
|
||||
parent::__construct($message);
|
||||
|
||||
$this->classname = $classname;
|
||||
}
|
||||
|
||||
public function getClassname()
|
||||
{
|
||||
return $this->classname;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Prophecy.
|
||||
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
* Marcello Duarte <marcello.duarte@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Prophecy\Exception\Doubler;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class DoubleException extends RuntimeException implements DoublerException
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Prophecy.
|
||||
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
* Marcello Duarte <marcello.duarte@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Prophecy\Exception\Doubler;
|
||||
|
||||
use Prophecy\Exception\Exception;
|
||||
|
||||
interface DoublerException extends Exception
|
||||
{
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Prophecy.
|
||||
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
* Marcello Duarte <marcello.duarte@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Prophecy\Exception\Doubler;
|
||||
|
||||
class InterfaceNotFoundException extends ClassNotFoundException
|
||||
{
|
||||
public function getInterfaceName()
|
||||
{
|
||||
return $this->getClassname();
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Prophecy\Exception\Doubler;
|
||||
|
||||
class MethodNotExtendableException extends DoubleException
|
||||
{
|
||||
private $methodName;
|
||||
|
||||
private $className;
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
* @param string $className
|
||||
* @param string $methodName
|
||||
*/
|
||||
public function __construct($message, $className, $methodName)
|
||||
{
|
||||
parent::__construct($message);
|
||||
|
||||
$this->methodName = $methodName;
|
||||
$this->className = $className;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMethodName()
|
||||
{
|
||||
return $this->methodName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName()
|
||||
{
|
||||
return $this->className;
|
||||
}
|
||||
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Prophecy.
|
||||
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
* Marcello Duarte <marcello.duarte@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Prophecy\Exception\Doubler;
|
||||
|
||||
class MethodNotFoundException extends DoubleException
|
||||
{
|
||||
/**
|
||||
* @var string|object
|
||||
*/
|
||||
private $classname;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $methodName;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $arguments;
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
* @param string|object $classname
|
||||
* @param string $methodName
|
||||
* @param null|Argument\ArgumentsWildcard|array $arguments
|
||||
*/
|
||||
public function __construct($message, $classname, $methodName, $arguments = null)
|
||||
{
|
||||
parent::__construct($message);
|
||||
|
||||
$this->classname = $classname;
|
||||
$this->methodName = $methodName;
|
||||
$this->arguments = $arguments;
|
||||
}
|
||||
|
||||
public function getClassname()
|
||||
{
|
||||
return $this->classname;
|
||||
}
|
||||
|
||||
public function getMethodName()
|
||||
{
|
||||
return $this->methodName;
|
||||
}
|
||||
|
||||
public function getArguments()
|
||||
{
|
||||
return $this->arguments;
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Prophecy.
|
||||
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
* Marcello Duarte <marcello.duarte@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Prophecy\Exception\Doubler;
|
||||
|
||||
class ReturnByReferenceException extends DoubleException
|
||||
{
|
||||
private $classname;
|
||||
private $methodName;
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
* @param string $classname
|
||||
* @param string $methodName
|
||||
*/
|
||||
public function __construct($message, $classname, $methodName)
|
||||
{
|
||||
parent::__construct($message);
|
||||
|
||||
$this->classname = $classname;
|
||||
$this->methodName = $methodName;
|
||||
}
|
||||
|
||||
public function getClassname()
|
||||
{
|
||||
return $this->classname;
|
||||
}
|
||||
|
||||
public function getMethodName()
|
||||
{
|
||||
return $this->methodName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Prophecy.
|
||||
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
* Marcello Duarte <marcello.duarte@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Prophecy\Exception;
|
||||
|
||||
/**
|
||||
* Core Prophecy exception interface.
|
||||
* All Prophecy exceptions implement it.
|
||||
*
|
||||
* @author Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
*/
|
||||
interface Exception extends \Throwable
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Prophecy.
|
||||
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
* Marcello Duarte <marcello.duarte@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Prophecy\Exception;
|
||||
|
||||
class InvalidArgumentException extends \InvalidArgumentException implements Exception
|
||||
{
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Prophecy.
|
||||
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
* Marcello Duarte <marcello.duarte@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Prophecy\Exception\Prediction;
|
||||
|
||||
use Prophecy\Prophecy\ObjectProphecy;
|
||||
|
||||
class AggregateException extends \RuntimeException implements PredictionException
|
||||
{
|
||||
private $exceptions = array();
|
||||
private $objectProphecy;
|
||||
|
||||
public function append(PredictionException $exception)
|
||||
{
|
||||
$message = $exception->getMessage();
|
||||
$message = strtr($message, array("\n" => "\n "))."\n";
|
||||
$message = empty($this->exceptions) ? $message : "\n" . $message;
|
||||
|
||||
$this->message = rtrim($this->message.$message);
|
||||
$this->exceptions[] = $exception;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PredictionException[]
|
||||
*/
|
||||
public function getExceptions()
|
||||
{
|
||||
return $this->exceptions;
|
||||
}
|
||||
|
||||
public function setObjectProphecy(ObjectProphecy $objectProphecy)
|
||||
{
|
||||
$this->objectProphecy = $objectProphecy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ObjectProphecy
|
||||
*/
|
||||
public function getObjectProphecy()
|
||||
{
|
||||
return $this->objectProphecy;
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Prophecy.
|
||||
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
* Marcello Duarte <marcello.duarte@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Prophecy\Exception\Prediction;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Basic failed prediction exception.
|
||||
* Use it for custom prediction failures.
|
||||
*
|
||||
* @author Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
*/
|
||||
class FailedPredictionException extends RuntimeException implements PredictionException
|
||||
{
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Prophecy.
|
||||
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
* Marcello Duarte <marcello.duarte@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Prophecy\Exception\Prediction;
|
||||
|
||||
use Prophecy\Exception\Prophecy\MethodProphecyException;
|
||||
|
||||
class NoCallsException extends MethodProphecyException implements PredictionException
|
||||
{
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Prophecy.
|
||||
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
* Marcello Duarte <marcello.duarte@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Prophecy\Exception\Prediction;
|
||||
|
||||
use Prophecy\Exception\Exception;
|
||||
|
||||
interface PredictionException extends Exception
|
||||
{
|
||||
}
|
||||
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Prophecy.
|
||||
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
* Marcello Duarte <marcello.duarte@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Prophecy\Exception\Prediction;
|
||||
|
||||
use Prophecy\Prophecy\MethodProphecy;
|
||||
|
||||
class UnexpectedCallsCountException extends UnexpectedCallsException
|
||||
{
|
||||
private $expectedCount;
|
||||
|
||||
public function __construct($message, MethodProphecy $methodProphecy, $count, array $calls)
|
||||
{
|
||||
parent::__construct($message, $methodProphecy, $calls);
|
||||
|
||||
$this->expectedCount = intval($count);
|
||||
}
|
||||
|
||||
public function getExpectedCount()
|
||||
{
|
||||
return $this->expectedCount;
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Prophecy.
|
||||
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
* Marcello Duarte <marcello.duarte@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Prophecy\Exception\Prediction;
|
||||
|
||||
use Prophecy\Prophecy\MethodProphecy;
|
||||
use Prophecy\Exception\Prophecy\MethodProphecyException;
|
||||
|
||||
class UnexpectedCallsException extends MethodProphecyException implements PredictionException
|
||||
{
|
||||
private $calls = array();
|
||||
|
||||
public function __construct($message, MethodProphecy $methodProphecy, array $calls)
|
||||
{
|
||||
parent::__construct($message, $methodProphecy);
|
||||
|
||||
$this->calls = $calls;
|
||||
}
|
||||
|
||||
public function getCalls()
|
||||
{
|
||||
return $this->calls;
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Prophecy.
|
||||
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
* Marcello Duarte <marcello.duarte@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Prophecy\Exception\Prophecy;
|
||||
|
||||
use Prophecy\Prophecy\MethodProphecy;
|
||||
|
||||
class MethodProphecyException extends ObjectProphecyException
|
||||
{
|
||||
private $methodProphecy;
|
||||
|
||||
public function __construct($message, MethodProphecy $methodProphecy)
|
||||
{
|
||||
parent::__construct($message, $methodProphecy->getObjectProphecy());
|
||||
|
||||
$this->methodProphecy = $methodProphecy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MethodProphecy
|
||||
*/
|
||||
public function getMethodProphecy()
|
||||
{
|
||||
return $this->methodProphecy;
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Prophecy.
|
||||
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
* Marcello Duarte <marcello.duarte@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Prophecy\Exception\Prophecy;
|
||||
|
||||
use Prophecy\Prophecy\ObjectProphecy;
|
||||
|
||||
class ObjectProphecyException extends \RuntimeException implements ProphecyException
|
||||
{
|
||||
private $objectProphecy;
|
||||
|
||||
public function __construct($message, ObjectProphecy $objectProphecy)
|
||||
{
|
||||
parent::__construct($message);
|
||||
|
||||
$this->objectProphecy = $objectProphecy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ObjectProphecy
|
||||
*/
|
||||
public function getObjectProphecy()
|
||||
{
|
||||
return $this->objectProphecy;
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Prophecy.
|
||||
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
* Marcello Duarte <marcello.duarte@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Prophecy\Exception\Prophecy;
|
||||
|
||||
use Prophecy\Exception\Exception;
|
||||
|
||||
interface ProphecyException extends Exception
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user