2016-09-10 01:41:21 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace bkrukowski\Gordianus\Tests\Services;
|
|
|
|
|
|
|
|
use bkrukowski\Gordianus\Services\GmailCOM;
|
|
|
|
|
|
|
|
class GmailCOMTest extends \PHPUnit_Framework_TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @dataProvider providerGetPrimaryEmail
|
|
|
|
*
|
|
|
|
* @param string $inputEmail
|
|
|
|
* @param string $outputEmail
|
|
|
|
*/
|
|
|
|
public function testGetPrimaryEmail(string $inputEmail, string $outputEmail)
|
|
|
|
{
|
|
|
|
$this->assertSame($outputEmail, (new GmailCOM())->getPrimaryEmail($inputEmail));
|
|
|
|
}
|
|
|
|
|
|
|
|
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'],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider providerIsDomainSupported
|
|
|
|
*
|
|
|
|
* @param string $domain
|
|
|
|
* @param bool $result
|
|
|
|
*/
|
|
|
|
public function testIsDomainSupported(string $domain, bool $result)
|
|
|
|
{
|
|
|
|
$this->assertSame($result, (new GmailCOM())->isDomainSupported($domain));
|
|
|
|
}
|
|
|
|
|
|
|
|
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]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|