jeudi 27 août 2015

PHP Mockery: how to set expectation on a method OR another method?

I'm trying to use Mockery and PHPUnit to test if one method OR another method of a given class will be called when some piece of code is executed.

This is exactly what I'm trying to do (I'm using Laravel 5):

// Test an email is sent to new user
// upon account creation.
public function testEmailSentOnNewUserCreation()
{
    // Mail can be sent right on ...
    Mail::shouldReceive('send')->once(); //...OR...
    // ... it can be queued for later.
    Mail::shouldReceive('queue')->once();
    // I'm ignoring parameters and returning values here
    // for sake of brevity.

    $u = new User;
    $u->name = 'Jon Doe';
    $u->email = 'jon@doe.com';
    $u->save();
}

So, my question is about how to implement the OR part, if it's possible. I also searched for some PHPUnit annotation that could be helpful, but I couldn't find anything.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1hhdiER
via IFTTT

Aucun commentaire:

Enregistrer un commentaire