Created
May 1, 2014 23:49
-
-
Save shadowhand/6dc65f72e2f9de225925 to your computer and use it in GitHub Desktop.
spec for "user can register" use case
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 spec\Ushahidi\Usecase\User; | |
use Ushahidi\Entity\User; | |
use Ushahidi\Entity\UserRepository; | |
use Ushahidi\Tool\Validator; | |
use PhpSpec\ObjectBehavior; | |
use Prophecy\Argument; | |
class RegisterSpec extends ObjectBehavior | |
{ | |
function let(UserRepository $repo, Validator $valid, User $user) | |
{ | |
$user->beConstructedWith([]); | |
$user->email = 'test@example.com'; | |
$user->username = 'test'; | |
$user->password = 'secret'; | |
$this->beConstructedWith($repo, $valid); | |
} | |
function it_is_initializable() | |
{ | |
$this->shouldHaveType('Ushahidi\Usecase\User\Register'); | |
} | |
function it_does_interact_with_the_validator_and_repository($repo, $valid, $user) | |
{ | |
$valid->check($user)->shouldBeCalled()->willReturn(true); | |
$repo->add($user)->shouldBeCalled()->willReturn(1); | |
$this->interact($user); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment