I am testing an object that is intended to be tested if the user owns this email. Therefore, when the "tryEmail" method is called, it sends a message with a confirmation link to the specified email address. My test is as follows:
public function testSendingWasSuccessful() {
$confirmationObject = $this->getMock('LT\EmailConfirmation\Model\ConfirmationObjectInterface');
$testType = 'test.type';
$testEmail = 'test@example.com';
$testData = [];
$this->manager->expects(static::once())
->method('create')->with($testType, $testEmail)
->willReturn($confirmationObject);
$this->mailer->expects(static::once())
->method('send')->with(static::identicalTo($confirmationObject))
->willReturn(true);
$this->manager->expects(static::once())
->method('save')->with(static::identicalTo($confirmationObject));
$tester = new EmailTester($this->repository, $this->manager, $this->confirmationHandler, $this->mailer);
static::assertTrue($tester->tryEmail($testType, $testEmail, $testData));
}
, , , - . ? . , , , , "tryEmail" .
, tryEmail . , , , , , . , , . : static::identicalTo($confirmationObject), : check if the object passed to the mailer is the same as the one created before. , EmailTester, , - . - ? , , ?
? ? ?
: - , ( )? , , . , . ?