mailgun-php/tests/Mailgun/Tests/Lists/OptInHandlerTest.php
Iain Cambridge 3af838f2c8 Move mocks
Created a Mocks directory to seperate mocks from classes.

I moved Mailgun\Tests\MailGunTest to Mailgun\Test\Mocks\Mailgun. As it's not a
test it's a mock. So shouldn't be suffixed with Test.

I mocked Mailgun\Tests\Connection\TestBroker to Mailgun\Tests\Mocks\Connection\TestBroker as it's a mock and should be with other mocks.
2014-05-13 14:25:26 +01:00

33 lines
1.5 KiB
PHP

<?PHP
namespace Mailgun\Tests\Lists;
use Mailgun\Tests\Mock\Mailgun;
class OptInHandler extends \Mailgun\Tests\MailgunTestCase{
private $client;
private $sampleDomain = "samples.mailgun.org";
private $optInHandler;
public function setUp(){
$this->client = new Mailgun("My-Super-Awesome-API-Key");
$this->optInHandler = $this->client->OptInHandler();
}
public function testReturnOfGenerateHash(){
$generatedHash = $this->optInHandler->generateHash('mytestlist@example.com', 'mysupersecretappid', 'testrecipient@example.com');
$knownHash = "eyJoIjoiMTllODc2YWNkMWRmNzk4NTc0ZTU0YzhjMzIzOTNiYTNjNzdhNGMxOCIsInAiOiJleUp5SWpvaWRHVnpkSEpsWTJsd2FXVnVkRUJsZUdGdGNHeGxMbU52YlNJc0ltd2lPaUp0ZVhSbGMzUnNhWE4wUUdWNFlXMXdiR1V1WTI5dEluMD0ifQ%3D%3D";
$this->assertEquals($generatedHash, $knownHash);
}
public function testGoodHash(){
$validation = $this->optInHandler->validateHash('mysupersecretappid', 'eyJoIjoiMTllODc2YWNkMWRmNzk4NTc0ZTU0YzhjMzIzOTNiYTNjNzdhNGMxOCIsInAiOiJleUp5SWpvaWRHVnpkSEpsWTJsd2FXVnVkRUJsZUdGdGNHeGxMbU52YlNJc0ltd2lPaUp0ZVhSbGMzUnNhWE4wUUdWNFlXMXdiR1V1WTI5dEluMD0ifQ%3D%3D');
$this->assertArrayHasKey('recipientAddress', $validation);
$this->assertArrayHasKey('mailingList', $validation);
}
public function testBadHash(){
$validation = $this->optInHandler->validateHash('mybadsecretappid', 'eyJoIjoiMTllODc2YWNkMWRmNzk4NTc0ZTU0YzhjMzIzOTNiYTNjNzdhNGMxOCIsInAiOiJleUp5SWpvaWRHVnpkSEpsWTJsd2FXVnVkRUJsZUdGdGNHeGxMbU52YlNJc0ltd2lPaUp0ZVhSbGMzUnNhWE4wUUdWNFlXMXdiR1V1WTI5dEluMD0ifQ%3D%3D');
$this->assertFalse($validation);
}
}
?>