Groups
Groups
Sign in
Groups
Groups
PHPSpec - Behavior Driven Design (BDD) for PHP
Conversations
About
Send feedback
Help
Hot to spec behaviour that calls class methods
43 views
Skip to first unread message
Gonzalo Vilaseca
unread,
Aug 7, 2014, 4:59:33 AM
8/7/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to phpsp...@googlegroups.com
So I have this method:
public function newWishlist($user)
{
$wishlist = $this->createNew();
$wishlist->setUser($user);
$this->persistAndFlush($wishlist);
return $wishlist;
}
My first approach was to spec it this way:
$this->createNew()->willReturn($wishlist);
$wishlist->setUser($user)->shouldBeCalled()->willReturn($wishlist);
$this->persistAndFlush($wishlist)->shouldBeCalled();
$this->newWishlist($user);
But this throwed an error because I was mocking calls to the SUS, so I had to follow another approach:
$wishlist = $this->newWishlist($user);
$wishlist->getUser()->shouldReturn($user);
Is this second approach correct? Instead of mocking, I'm checking behaviour after the call.
Reply all
Reply to author
Forward
0 new messages