transparent-email/tests/Services/GmailComTest.php

58 lines
1.6 KiB
PHP
Raw Permalink Normal View History

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-24 13:09:20 +03:00
use bkrukowski\TransparentEmail\Emails\Email;
2016-09-10 16:13:55 +03:00
use bkrukowski\TransparentEmail\Services\GmailCom;
2020-02-13 16:27:05 +03:00
use PHPUnit\Framework\TestCase;
2016-09-10 01:41:21 +03:00
2020-02-13 16:27:05 +03:00
class GmailComTest extends 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-24 13:09:20 +03:00
$this->assertEquals($outputEmail, (new GmailCom())->getPrimaryEmail(new Email($inputEmail)));
2016-09-10 01:41:21 +03:00
}
2016-10-14 21:25:52 +03:00
public function providerGetPrimaryEmail() : array
2016-09-10 01:41:21 +03:00
{
return [
['foo.bar@gmail.com', 'foobar@gmail.com'],
['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
];
}
/**
2016-09-24 13:09:20 +03:00
* @dataProvider providerIsSupported
2016-09-10 01:41:21 +03:00
*
* @param string $domain
* @param bool $result
*/
2016-09-24 13:09:20 +03:00
public function testIsSupported(string $domain, bool $result)
2016-09-10 01:41:21 +03:00
{
2016-09-24 13:09:20 +03:00
$this->assertSame($result, (new GmailCom())->isSupported(new Email('Jane.Doe@' . $domain)));
2016-09-10 01:41:21 +03:00
}
2016-10-14 21:25:52 +03:00
public function providerIsSupported() : array
2016-09-10 01:41:21 +03:00
{
return [
['gmail.com', true],
['gmail.COM', true],
2016-09-10 01:41:21 +03:00
['google.com', false],
2016-09-24 13:09:20 +03:00
['test.gmailcom', false],
['g.mail.com', false],
['googlemail.com', true],
['GoogleMail.Com', true],
2016-09-10 01:41:21 +03:00
];
}
}