Created
December 2, 2013 20:09
-
-
Save fiunchinho/7757712 to your computer and use it in GitHub Desktop.
Triying to describe in PHPSpec that using wrong parameters throws exception
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace MyApp; | |
use PhpSpec\ObjectBehavior; | |
use Prophecy\Argument; | |
class UserSpec extends ObjectBehavior | |
{ | |
function it_fails_when_using_a_not_valid_email() | |
{ | |
// Needs to be constructed with a valid email first :(:( | |
$this->beConstructedWith( 'valid@email.com' ); | |
$this->shouldThrow( '\InvalidArgumentException' )->during( '__construct', array( 'wrong_email' ) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Since PHPSpec creates the object before hand, you need to first instantiate the object with valid arguments. Otherwise the exception will be thrown BEFORE being expected, so phpspec will complain because