ThrowPromiseSpec.php (1645B)
1 <?php 2 3 namespace spec\Prophecy\Promise; 4 5 use PhpSpec\ObjectBehavior; 6 7 class ThrowPromiseSpec extends ObjectBehavior 8 { 9 function let() 10 { 11 $this->beConstructedWith('RuntimeException'); 12 } 13 14 function it_is_promise() 15 { 16 $this->shouldBeAnInstanceOf('Prophecy\Promise\PromiseInterface'); 17 } 18 19 /** 20 * @param \Prophecy\Prophecy\ObjectProphecy $object 21 * @param \Prophecy\Prophecy\MethodProphecy $method 22 */ 23 function it_instantiates_and_throws_exception_from_provided_classname($object, $method) 24 { 25 $this->beConstructedWith('InvalidArgumentException'); 26 27 $this->shouldThrow('InvalidArgumentException') 28 ->duringExecute(array(), $object, $method); 29 } 30 31 /** 32 * @param \Prophecy\Prophecy\ObjectProphecy $object 33 * @param \Prophecy\Prophecy\MethodProphecy $method 34 */ 35 function it_instantiates_exceptions_with_required_arguments($object, $method) 36 { 37 $this->beConstructedWith('spec\Prophecy\Promise\RequiredArgumentException'); 38 39 $this->shouldThrow('spec\Prophecy\Promise\RequiredArgumentException') 40 ->duringExecute(array(), $object, $method); 41 } 42 43 /** 44 * @param \Prophecy\Prophecy\ObjectProphecy $object 45 * @param \Prophecy\Prophecy\MethodProphecy $method 46 */ 47 function it_throws_provided_exception($object, $method) 48 { 49 $this->beConstructedWith($exc = new \RuntimeException('Some exception')); 50 51 $this->shouldThrow($exc)->duringExecute(array(), $object, $method); 52 } 53 } 54 55 class RequiredArgumentException extends \Exception 56 { 57 final public function __construct($message, $code) {} 58 }