Chris@16: assertInstanceOf('Psy\Exception\Exception', $e); Chris@16: $this->assertInstanceOf('Psy\Exception\ThrowUpException', $e); Chris@16: Chris@16: $this->assertEquals("Throwing Exception with message '{{message}}'", $e->getMessage()); Chris@16: $this->assertEquals('{{message}}', $e->getRawMessage()); Chris@16: $this->assertEquals(123, $e->getCode()); Chris@16: $this->assertSame($previous, $e->getPrevious()); Chris@16: } Chris@16: Chris@16: public function testFromThrowable() Chris@16: { Chris@16: $previous = new \Exception('{{message}}'); Chris@16: $e = ThrowUpException::fromThrowable($previous); Chris@16: Chris@16: $this->assertInstanceOf('Psy\Exception\ThrowUpException', $e); Chris@16: $this->assertSame($previous, $e->getPrevious()); Chris@16: } Chris@16: Chris@16: public function testFromThrowableWithError() Chris@16: { Chris@17: if (\version_compare(PHP_VERSION, '7.0.0', '<')) { Chris@16: $this->markTestSkipped(); Chris@16: } Chris@16: Chris@16: $previous = new \Error('{{message}}'); Chris@16: $e = ThrowUpException::fromThrowable($previous); Chris@16: Chris@16: $this->assertInstanceOf('Psy\Exception\ThrowUpException', $e); Chris@16: $this->assertInstanceOf('Psy\Exception\ErrorException', $e->getPrevious()); Chris@16: Chris@16: $this->assertNotSame($previous, $e->getPrevious()); Chris@16: $this->assertSame($previous, $e->getPrevious()->getPrevious()); Chris@16: } Chris@16: Chris@16: /** Chris@16: * @expectedException \InvalidArgumentException Chris@16: * @expectedExceptionMessage throw-up can only throw Exceptions and Errors Chris@16: */ Chris@16: public function testFromThrowableThrowsError() Chris@16: { Chris@16: $notThrowable = new \StdClass(); Chris@16: ThrowUpException::fromThrowable($notThrowable); Chris@16: } Chris@16: }