mailgun-php/tests/Mailgun/Tests/Lists/OptInHandlerTest.php

33 lines
1.5 KiB
PHP
Raw Normal View History

2013-08-16 22:20:01 +04:00
<?PHP
namespace Mailgun\Tests\Lists;
use Mailgun\Tests\MailgunTest;
class OptInHandler extends \Mailgun\Tests\MailgunTestCase{
private $client;
private $sampleDomain = "samples.mailgun.org";
private $optInHandler;
public function setUp(){
$this->client = new MailgunTest("My-Super-Awesome-API-Key");
$this->optInHandler = $this->client->OptInHandler();
}
public function testReturnOfGenerateHash(){
$generatedHash = $this->optInHandler->generateHash('mytestlist@example.com', 'mysupersecretappid', 'testrecipient@example.com');
2014-01-25 00:32:51 +04:00
$knownHash = "eyJoIjoiMTllODc2YWNkMWRmNzk4NTc0ZTU0YzhjMzIzOTNiYTNjNzdhNGMxOCIsInAiOiJleUp5SWpvaWRHVnpkSEpsWTJsd2FXVnVkRUJsZUdGdGNHeGxMbU52YlNJc0ltd2lPaUp0ZVhSbGMzUnNhWE4wUUdWNFlXMXdiR1V1WTI5dEluMD0ifQ%3D%3D";
2013-08-16 22:20:01 +04:00
$this->assertEquals($generatedHash, $knownHash);
}
public function testGoodHash(){
2014-01-25 00:32:51 +04:00
$validation = $this->optInHandler->validateHash('mysupersecretappid', 'eyJoIjoiMTllODc2YWNkMWRmNzk4NTc0ZTU0YzhjMzIzOTNiYTNjNzdhNGMxOCIsInAiOiJleUp5SWpvaWRHVnpkSEpsWTJsd2FXVnVkRUJsZUdGdGNHeGxMbU52YlNJc0ltd2lPaUp0ZVhSbGMzUnNhWE4wUUdWNFlXMXdiR1V1WTI5dEluMD0ifQ%3D%3D');
2013-08-20 02:02:07 +04:00
$this->assertArrayHasKey('recipientAddress', $validation);
$this->assertArrayHasKey('mailingList', $validation);
2013-08-16 22:20:01 +04:00
}
public function testBadHash(){
2014-01-25 00:32:51 +04:00
$validation = $this->optInHandler->validateHash('mybadsecretappid', 'eyJoIjoiMTllODc2YWNkMWRmNzk4NTc0ZTU0YzhjMzIzOTNiYTNjNzdhNGMxOCIsInAiOiJleUp5SWpvaWRHVnpkSEpsWTJsd2FXVnVkRUJsZUdGdGNHeGxMbU52YlNJc0ltd2lPaUp0ZVhSbGMzUnNhWE4wUUdWNFlXMXdiR1V1WTI5dEluMD0ifQ%3D%3D');
2013-08-16 22:20:01 +04:00
$this->assertFalse($validation);
}
}
?>