public function testErrorCronSending() { $Postman = \rmrevin\yii\postman\Component::get(); $Mailer = $Postman->getMailerObject(); $Mailer->IsSMTP(); $Letter = (new postman\RawLetter())->setSubject('Test error cron sending')->setBody('body')->setFrom(['*****@*****.**', 'Test'])->addAddress(\Yii::$app->params['demo_email'], ['*****@*****.**'], ['*****@*****.**'], ['*****@*****.**']); $Letter->send(); $Letter->send(); $Letter->send(); $Letter->send(); $Letter->send(); $count = postman\models\LetterModel::find()->where(['date_send' => null])->count(); $this->assertEquals(5, $count); $this->expectException('yii\\base\\Exception'); postman\models\LetterModel::cron(1); }
public function testErrorCronSending() { $Postman = \rmrevin\yii\postman\Component::get(); $Mailer = $Postman->getMailerObject(); $Mailer->IsSMTP(); $Mailer->Host = 'smtp.google.com'; $Mailer->Username = '******'; $Letter = (new postman\RawLetter())->setSubject('Test cron sending')->setBody('body')->setFrom(['*****@*****.**', 'Test'])->addAddress(\Yii::$app->params['demo_email'], ['*****@*****.**'], ['*****@*****.**'], ['*****@*****.**']); $Letter->send(); $Letter->send(); $Letter->send(); $Letter->send(); $Letter->send(); $count = postman\models\LetterModel::find()->where(['date_send' => null])->count(); $this->assertEquals(5, $count); postman\models\LetterModel::cron(1); $this->expectOutputString('The following From address failed: test@domain.com : Called Mail() without being connected' . "\n"); }
/** * @depends testMain * @param \rmrevin\yii\postman\ViewLetter $Letter * @throws \rmrevin\yii\postman\Exception */ public function testSendSMTP(postman\ViewLetter $Letter) { $Postman = \rmrevin\yii\postman\Component::get(); $Postman->driver = 'smtp'; $Postman->reconfigureDriver(); $Letter->setSubject('SMTP html letter'); $this->assertInternalType('integer', $Letter->send()); $this->assertInternalType('integer', $Letter->send(true)); $this->assertEmpty($Letter->getLastError(), $Letter->getLastError()); $count = postman\models\LetterModel::find()->where(['subject' => 'SMTP html letter'])->count(); $this->assertEquals(2, $count); }