PMCORE-1159 SpoolRunTest: Solve the incomplete test
This commit is contained in:
@@ -90,25 +90,3 @@ $factory->state(\ProcessMaker\Model\EmailServerModel::class, 'GMAILAPI', functio
|
|||||||
'OAUTH_REFRESH_TOKEN' => $faker->regexify("/[a-z]{7}[a-zA-Z0-9]{355}==/")
|
'OAUTH_REFRESH_TOKEN' => $faker->regexify("/[a-z]{7}[a-zA-Z0-9]{355}==/")
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
$factory->state(\ProcessMaker\Model\EmailServerModel::class, 'OPENMAIL', function ($faker) {
|
|
||||||
return [
|
|
||||||
'MESS_UID' => G::generateUniqueID(),
|
|
||||||
'MESS_ENGINE' => 'OPENMAIL',
|
|
||||||
'MESS_PORT' => 0,
|
|
||||||
'MESS_INCOMING_SERVER' => '',
|
|
||||||
'MESS_INCOMING_PORT' => 0,
|
|
||||||
'MESS_RAUTH' => 1,
|
|
||||||
'MESS_ACCOUNT' => $faker->email,
|
|
||||||
'MESS_PASSWORD' => $faker->password,
|
|
||||||
'MESS_FROM_MAIL' => $faker->email,
|
|
||||||
'MESS_FROM_NAME' => $faker->name,
|
|
||||||
'SMTPSECURE' => 'ssl',
|
|
||||||
'MESS_TRY_SEND_INMEDIATLY' => 0,
|
|
||||||
'MAIL_TO' => $faker->email,
|
|
||||||
'MESS_DEFAULT' => 0,
|
|
||||||
'OAUTH_CLIENT_ID' => '',
|
|
||||||
'OAUTH_CLIENT_SECRET' => '',
|
|
||||||
'OAUTH_REFRESH_TOKEN' => ''
|
|
||||||
];
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -190,47 +190,6 @@ class SpoolRunTest extends TestCase
|
|||||||
$this->assertTrue($expected);
|
$this->assertTrue($expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This test uses the OPENMAIL option in a simple way.
|
|
||||||
* @test
|
|
||||||
* @covers \SpoolRun::__construct()
|
|
||||||
* @covers \SpoolRun::setData()
|
|
||||||
* @covers \SpoolRun::setConfig()
|
|
||||||
* @covers \SpoolRun::sendMail()
|
|
||||||
* @covers \SpoolRun::handleMail()
|
|
||||||
*/
|
|
||||||
public function it_should_handle_open_mail_option()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete("The OPENMAIL depends on the package class but this is not found in the environment.");
|
|
||||||
|
|
||||||
$appMsgUid = G::generateUniqueID();
|
|
||||||
factory(AppMessage::class)->create([
|
|
||||||
'APP_MSG_UID' => $appMsgUid
|
|
||||||
]);
|
|
||||||
|
|
||||||
$emailServer = factory(EmailServerModel::class)->states('OPENMAIL')->make();
|
|
||||||
|
|
||||||
$config = $emailServer->toArray();
|
|
||||||
|
|
||||||
$faker = Factory::create();
|
|
||||||
$spoolRun = new SpoolRun();
|
|
||||||
$spoolRun->setData(
|
|
||||||
$appMsgUid,
|
|
||||||
$faker->title,
|
|
||||||
$faker->companyEmail,
|
|
||||||
$faker->freeEmail,
|
|
||||||
$faker->text(),
|
|
||||||
$faker->dateTime()->format('Y-m-d H:i:s'),
|
|
||||||
$faker->companyEmail,
|
|
||||||
$faker->freeEmail
|
|
||||||
);
|
|
||||||
$spoolRun->setConfig($config);
|
|
||||||
|
|
||||||
$expected = $spoolRun->sendMail();
|
|
||||||
|
|
||||||
$this->assertTrue($expected);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This test ensures that characters that are not utf8 are converted properly,
|
* This test ensures that characters that are not utf8 are converted properly,
|
||||||
* for subject and body fields.
|
* for subject and body fields.
|
||||||
|
|||||||
@@ -674,42 +674,6 @@ class SpoolRun
|
|||||||
$this->updateSpoolError($error->getMessage());
|
$this->updateSpoolError($error->getMessage());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'OPENMAIL':
|
|
||||||
$pack = new package($this->fileData);
|
|
||||||
$header = $pack->returnHeader();
|
|
||||||
$body = $pack->returnBody();
|
|
||||||
$send = new smtp();
|
|
||||||
$send->setServer($this->config['MESS_SERVER']);
|
|
||||||
$send->setPort($this->config['MESS_PORT']);
|
|
||||||
$send->setUsername($this->config['MESS_ACCOUNT']);
|
|
||||||
|
|
||||||
$passwd = $this->config['MESS_PASSWORD'];
|
|
||||||
$passwdDec = G::decrypt($passwd, 'EMAILENCRYPT');
|
|
||||||
$auxPass = explode('hash:', $passwdDec);
|
|
||||||
|
|
||||||
if (count($auxPass) > 1) {
|
|
||||||
if (count($auxPass) == 2) {
|
|
||||||
$passwd = $auxPass[1];
|
|
||||||
} else {
|
|
||||||
array_shift($auxPass);
|
|
||||||
$passwd = implode('', $auxPass);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->config['MESS_PASSWORD'] = $passwd;
|
|
||||||
$send->setPassword($this->config['MESS_PASSWORD']);
|
|
||||||
$send->setReturnPath($this->fileData['from_email']);
|
|
||||||
$send->setHeaders($header);
|
|
||||||
$send->setBody($body);
|
|
||||||
$send->setEnvelopeTo($this->fileData['envelope_to']);
|
|
||||||
if ($send->sendMessage()) {
|
|
||||||
$this->error = '';
|
|
||||||
$this->status = 'sent';
|
|
||||||
} else {
|
|
||||||
$this->error = implode(', ', $send->returnErrors());
|
|
||||||
$this->status = 'failed';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user