From 94119d07e3d8951e205288288dd695e3f4c7cb5a Mon Sep 17 00:00:00 2001 From: bkrukowski Date: Fri, 16 Sep 2016 01:13:48 +0200 Subject: [PATCH] Support for apps.google.com --- src/Services/AppsGoogleCom.php | 23 +++++++++++++++++++++++ src/Services/GmailCom.php | 10 +++++++++- src/TransparentEmail.php | 3 +++ tests/Services/AppsGoogleComTest.php | 27 +++++++++++++++++++++++++++ tests/Services/GmailComTest.php | 2 +- 5 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 src/Services/AppsGoogleCom.php create mode 100644 tests/Services/AppsGoogleComTest.php diff --git a/src/Services/AppsGoogleCom.php b/src/Services/AppsGoogleCom.php new file mode 100644 index 0000000..4fbc6a4 --- /dev/null +++ b/src/Services/AppsGoogleCom.php @@ -0,0 +1,23 @@ +mapDomain($domain); } public function isDomainSupported(string $domain) : bool { return in_array(strtolower($domain), ['gmail.com', 'googlemail.com']); } + + private function mapDomain(string $domain) : string + { + $mapping = [ + 'googlemail.com' => 'gmail.com', + ]; + return $mapping[$domain] ?? $domain; + } } \ No newline at end of file diff --git a/src/TransparentEmail.php b/src/TransparentEmail.php index d88fab9..feed823 100644 --- a/src/TransparentEmail.php +++ b/src/TransparentEmail.php @@ -2,6 +2,7 @@ namespace bkrukowski\TransparentEmail; +use bkrukowski\TransparentEmail\Services\AppsGoogleCom; use bkrukowski\TransparentEmail\Services\GmailCom; use bkrukowski\TransparentEmail\Services\OutlookCom; use bkrukowski\TransparentEmail\Services\ServiceInterface; @@ -16,6 +17,7 @@ class TransparentEmail const SERVICE_WWW_33MAIL_COM = Www33MailCom::class; const SERVICE_OUTLOOK_COM = OutlookCom::class; const SERVICE_YAHOO_COM = YahooCom::class; + const SERVICE_APPS_GOOGLE_COM = AppsGoogleCom::class; /** * Constant ALL_SERVICES can contain different values depends on API version @@ -26,6 +28,7 @@ class TransparentEmail self::SERVICE_WWW_33MAIL_COM, self::SERVICE_OUTLOOK_COM, self::SERVICE_YAHOO_COM, + self::SERVICE_APPS_GOOGLE_COM, ]; private $services; diff --git a/tests/Services/AppsGoogleComTest.php b/tests/Services/AppsGoogleComTest.php new file mode 100644 index 0000000..28c2d35 --- /dev/null +++ b/tests/Services/AppsGoogleComTest.php @@ -0,0 +1,27 @@ +assertSame($result, (new AppsGoogleCom())->isDomainSupported($domain)); + } + + public function providerIsDomainSupported() + { + return [ + ['example.com', false], + ['krukowski.me', true], + ]; + } +} \ No newline at end of file diff --git a/tests/Services/GmailComTest.php b/tests/Services/GmailComTest.php index bed265a..84a27e2 100644 --- a/tests/Services/GmailComTest.php +++ b/tests/Services/GmailComTest.php @@ -24,7 +24,7 @@ class GmailComTest extends \PHPUnit_Framework_TestCase ['Foo.Bar@GMAIL.COM', 'foobar@gmail.com'], ['foobar+alias@gmail.com', 'foobar@gmail.com'], ['fo.ob.ar+alias@gmail.com', 'foobar@gmail.com'], - ['JaneDoe@googlemail.com', 'janedoe@googlemail.com'], + ['JaneDoe@googlemail.com', 'janedoe@gmail.com'], ]; }