Skip to content

Instantly share code, notes, and snippets.

@shadowhand
Created May 1, 2014 23:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shadowhand/6dc65f72e2f9de225925 to your computer and use it in GitHub Desktop.
Save shadowhand/6dc65f72e2f9de225925 to your computer and use it in GitHub Desktop.
spec for "user can register" use case
<?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