2016-09-10 01:41:21 +03:00
|
|
|
<?php
|
|
|
|
|
2016-09-23 22:39:33 +03:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2016-09-10 16:13:55 +03:00
|
|
|
namespace bkrukowski\TransparentEmail\Tests\Services;
|
2016-09-10 01:41:21 +03:00
|
|
|
|
2016-09-10 16:13:55 +03:00
|
|
|
use bkrukowski\TransparentEmail\Services\GmailCom;
|
2016-09-10 01:41:21 +03:00
|
|
|
|
2016-09-10 11:50:57 +03:00
|
|
|
class GmailComTest extends \PHPUnit_Framework_TestCase
|
2016-09-10 01:41:21 +03:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @dataProvider providerGetPrimaryEmail
|
|
|
|
*
|
|
|
|
* @param string $inputEmail
|
|
|
|
* @param string $outputEmail
|
|
|
|
*/
|
|
|
|
public function testGetPrimaryEmail(string $inputEmail, string $outputEmail)
|
|
|
|
{
|
2016-09-10 11:50:57 +03:00
|
|
|
$this->assertSame($outputEmail, (new GmailCom())->getPrimaryEmail($inputEmail));
|
2016-09-10 01:41:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public function providerGetPrimaryEmail()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
['foo.bar@gmail.com', 'foobar@gmail.com'],
|
2016-09-10 02:39:01 +03:00
|
|
|
['Foo.Bar@GMAIL.COM', 'foobar@gmail.com'],
|
2016-09-10 01:41:21 +03:00
|
|
|
['foobar+alias@gmail.com', 'foobar@gmail.com'],
|
|
|
|
['fo.ob.ar+alias@gmail.com', 'foobar@gmail.com'],
|
2016-09-16 02:13:48 +03:00
|
|
|
['JaneDoe@googlemail.com', 'janedoe@gmail.com'],
|
2016-09-10 01:41:21 +03:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider providerIsDomainSupported
|
|
|
|
*
|
|
|
|
* @param string $domain
|
|
|
|
* @param bool $result
|
|
|
|
*/
|
|
|
|
public function testIsDomainSupported(string $domain, bool $result)
|
|
|
|
{
|
2016-09-10 11:50:57 +03:00
|
|
|
$this->assertSame($result, (new GmailCom())->isDomainSupported($domain));
|
2016-09-10 01:41:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public function providerIsDomainSupported()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
['gmail.com', true],
|
2016-09-10 02:39:01 +03:00
|
|
|
['gmail.COM', true],
|
2016-09-10 01:41:21 +03:00
|
|
|
['google.com', false],
|
|
|
|
['gmailcom', false],
|
|
|
|
['g.mail.com', false]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|