3
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15
* This software consists of voluntary contributions made by many individuals
16
* and is licensed under the MIT license. For more information, see
17
* <http://www.doctrine-project.org>.
20
namespace DoctrineTest\InstantiatorTest\Exception;
22
use Doctrine\Instantiator\Exception\UnexpectedValueException;
24
use PHPUnit_Framework_TestCase;
28
* Tests for {@see \Doctrine\Instantiator\Exception\UnexpectedValueException}
30
* @author Marco Pivetta <ocramius@gmail.com>
32
* @covers \Doctrine\Instantiator\Exception\UnexpectedValueException
34
class UnexpectedValueExceptionTest extends PHPUnit_Framework_TestCase
36
public function testFromSerializationTriggeredException()
38
$reflectionClass = new ReflectionClass($this);
39
$previous = new Exception();
40
$exception = UnexpectedValueException::fromSerializationTriggeredException($reflectionClass, $previous);
42
$this->assertInstanceOf('Doctrine\\Instantiator\\Exception\\UnexpectedValueException', $exception);
43
$this->assertSame($previous, $exception->getPrevious());
45
'An exception was raised while trying to instantiate an instance of "'
46
. __CLASS__ . '" via un-serialization',
47
$exception->getMessage()
51
public function testFromUncleanUnSerialization()
53
$reflection = new ReflectionClass('DoctrineTest\\InstantiatorTestAsset\\AbstractClassAsset');
54
$exception = UnexpectedValueException::fromUncleanUnSerialization($reflection, 'foo', 123, 'bar', 456);
56
$this->assertInstanceOf('Doctrine\\Instantiator\\Exception\\UnexpectedValueException', $exception);
58
'Could not produce an instance of "DoctrineTest\\InstantiatorTestAsset\\AbstractClassAsset" '
59
. 'via un-serialization, since an error was triggered in file "bar" at line "456"',
60
$exception->getMessage()
63
$previous = $exception->getPrevious();
65
$this->assertInstanceOf('Exception', $previous);
66
$this->assertSame('foo', $previous->getMessage());
67
$this->assertSame(123, $previous->getCode());