transparent-email/tests/Services/OutlookComTest.php

63 lines
1.8 KiB
PHP
Raw Normal View History

2016-09-10 12:15:37 +02:00
<?php
2016-09-23 21:39:33 +02:00
declare(strict_types=1);
2016-09-10 15:13:55 +02:00
namespace bkrukowski\TransparentEmail\Tests\Services;
2016-09-10 12:15:37 +02:00
2016-09-24 12:09:20 +02:00
use bkrukowski\TransparentEmail\Emails\Email;
2016-09-10 15:13:55 +02:00
use bkrukowski\TransparentEmail\Services\OutlookCom;
2020-02-13 16:27:05 +03:00
use PHPUnit\Framework\TestCase;
2016-09-10 12:15:37 +02:00
2020-02-13 16:27:05 +03:00
class OutlookComTest extends TestCase
2016-09-10 12:15:37 +02:00
{
/**
2016-09-24 12:09:20 +02:00
* @dataProvider providerIsSupported
2016-09-10 12:15:37 +02:00
*
* @param string $domain
* @param bool $result
*/
2016-09-24 12:09:20 +02:00
public function testIsSupported(string $domain, bool $result)
2016-09-10 12:15:37 +02:00
{
2016-09-24 12:09:20 +02:00
$this->assertSame($result, (new OutlookCom())->isSupported(new Email('Jane.Doe@' . $domain, true)));
2016-09-10 12:15:37 +02:00
}
2016-10-14 20:25:52 +02:00
public function providerIsSupported() : array
2016-09-10 12:15:37 +02:00
{
return [
['outlook.com', true],
['Outlook.Com', true],
['hotmail.com', true],
2020-02-18 16:56:53 +03:00
['msn.com', true],
['live.com', true],
2016-09-10 12:15:37 +02:00
['HotMail.COM', true],
2020-02-18 16:56:53 +03:00
['Msn.COM', true],
['LIve.COM', true],
2016-09-10 12:15:37 +02:00
['gmail.com', false],
['tlen.pl', false],
];
}
/**
* @dataProvider providerGetPrimaryEmail
*
* @param string $inputEmail
* @param string $expectedEmail
*/
public function testGetPrimaryEmail(string $inputEmail, string $expectedEmail)
{
2016-09-24 12:09:20 +02:00
$this->assertEquals($expectedEmail, (new OutlookCom())->getPrimaryEmail(new Email($inputEmail, true)));
2016-09-10 12:15:37 +02:00
}
2016-10-14 20:25:52 +02:00
public function providerGetPrimaryEmail() : array
2016-09-10 12:15:37 +02:00
{
return [
['janedoe@outlook.com', 'janedoe@outlook.com'],
['jane.doe@outlook.com', 'jane.doe@outlook.com'],
['Jane.Doe@Outlook.Com', 'jane.doe@outlook.com'],
['Jane.Doe+alias@OUTLOOK.COM', 'jane.doe@outlook.com'],
['Jane.Doe+Hotmail@hotmail.com', 'jane.doe@hotmail.com'],
2020-02-18 16:56:53 +03:00
['Jane.Doe+Hotmail@live.com', 'jane.doe@live.com'],
['Jane.Doe+Hotmail@msn.com', 'jane.doe@msn.com'],
2016-09-10 12:15:37 +02:00
];
}
}