From d6e34bf43038419b2c5bea5573c7b161d33db690 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sun, 19 Oct 2025 21:09:27 +0100 Subject: [PATCH 1/3] Add Walla provider to Email class for enhanced email handling --- src/Emails/Canonicals/Providers/Walla.php | 46 ++++++++++++++ src/Emails/Email.php | 2 + tests/Canonicals/Providers/WallaTest.php | 75 +++++++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 src/Emails/Canonicals/Providers/Walla.php create mode 100644 tests/Canonicals/Providers/WallaTest.php diff --git a/src/Emails/Canonicals/Providers/Walla.php b/src/Emails/Canonicals/Providers/Walla.php new file mode 100644 index 0000000..bb7c345 --- /dev/null +++ b/src/Emails/Canonicals/Providers/Walla.php @@ -0,0 +1,46 @@ +toLowerCase($local); + + return [ + 'local' => $normalizedLocal, + 'domain' => self::CANONICAL_DOMAIN, + ]; + } + + public function getCanonicalDomain(): string + { + return self::CANONICAL_DOMAIN; + } + + public function getSupportedDomains(): array + { + return self::SUPPORTED_DOMAINS; + } +} diff --git a/src/Emails/Email.php b/src/Emails/Email.php index 9b57af3..2f06bfc 100644 --- a/src/Emails/Email.php +++ b/src/Emails/Email.php @@ -11,6 +11,7 @@ use Utopia\Emails\Canonicals\Providers\Icloud; use Utopia\Emails\Canonicals\Providers\Outlook; use Utopia\Emails\Canonicals\Providers\Protonmail; +use Utopia\Emails\Canonicals\Providers\Walla; use Utopia\Emails\Canonicals\Providers\Yahoo; class Email @@ -345,6 +346,7 @@ protected static function initializeProviders(): void new Icloud, new Protonmail, new Fastmail, + new Walla, ]; } } diff --git a/tests/Canonicals/Providers/WallaTest.php b/tests/Canonicals/Providers/WallaTest.php new file mode 100644 index 0000000..272edbf --- /dev/null +++ b/tests/Canonicals/Providers/WallaTest.php @@ -0,0 +1,75 @@ +provider = new Walla; + } + + public function testSupports(): void + { + $this->assertTrue($this->provider->supports('walla.co.il')); + $this->assertTrue($this->provider->supports('walla.com')); + $this->assertFalse($this->provider->supports('gmail.com')); + $this->assertFalse($this->provider->supports('outlook.com')); + $this->assertFalse($this->provider->supports('yahoo.com')); + $this->assertFalse($this->provider->supports('example.com')); + } + + public function testGetCanonical(): void + { + $testCases = [ + // walla.co.il domain + ['user.name', 'walla.co.il', 'user.name', 'walla.co.il'], + ['user.name+tag', 'walla.co.il', 'user.name+tag', 'walla.co.il'], + ['user.name+spam', 'walla.co.il', 'user.name+spam', 'walla.co.il'], + ['user.name+newsletter', 'walla.co.il', 'user.name+newsletter', 'walla.co.il'], + ['user.name+work', 'walla.co.il', 'user.name+work', 'walla.co.il'], + ['user.name+personal', 'walla.co.il', 'user.name+personal', 'walla.co.il'], + ['user.name+test123', 'walla.co.il', 'user.name+test123', 'walla.co.il'], + ['user.name+anything', 'walla.co.il', 'user.name+anything', 'walla.co.il'], + ['user.name+verylongtag', 'walla.co.il', 'user.name+verylongtag', 'walla.co.il'], + ['user.name+tag.with.dots', 'walla.co.il', 'user.name+tag.with.dots', 'walla.co.il'], + ['user.name+tag-with-hyphens', 'walla.co.il', 'user.name+tag-with-hyphens', 'walla.co.il'], + ['user.name+tag_with_underscores', 'walla.co.il', 'user.name+tag_with_underscores', 'walla.co.il'], + ['user.name+tag123', 'walla.co.il', 'user.name+tag123', 'walla.co.il'], + ['u.s.e.r.n.a.m.e', 'walla.co.il', 'u.s.e.r.n.a.m.e', 'walla.co.il'], + ['u.s.e.r.n.a.m.e+tag', 'walla.co.il', 'u.s.e.r.n.a.m.e+tag', 'walla.co.il'], + ['user+', 'walla.co.il', 'user+', 'walla.co.il'], + ['user.', 'walla.co.il', 'user.', 'walla.co.il'], + ['.user', 'walla.co.il', '.user', 'walla.co.il'], + ['user..name', 'walla.co.il', 'user..name', 'walla.co.il'], + // walla.com domain (should normalize to walla.co.il) + ['user.name+tag', 'walla.com', 'user.name+tag', 'walla.co.il'], + ['user.name+spam', 'walla.com', 'user.name+spam', 'walla.co.il'], + ['user.name', 'walla.com', 'user.name', 'walla.co.il'], + ['u.s.e.r.n.a.m.e', 'walla.com', 'u.s.e.r.n.a.m.e', 'walla.co.il'], + ['u.s.e.r.n.a.m.e+tag', 'walla.com', 'u.s.e.r.n.a.m.e+tag', 'walla.co.il'], + ]; + + foreach ($testCases as [$inputLocal, $inputDomain, $expectedLocal, $expectedDomain]) { + $result = $this->provider->getCanonical($inputLocal, $inputDomain); + $this->assertEquals($expectedLocal, $result['local'], "Failed for local: {$inputLocal}@{$inputDomain}"); + $this->assertEquals($expectedDomain, $result['domain'], "Failed for domain: {$inputLocal}@{$inputDomain}"); + } + } + + public function testGetCanonicalDomain(): void + { + $this->assertEquals('walla.co.il', $this->provider->getCanonicalDomain()); + } + + public function testGetSupportedDomains(): void + { + $domains = $this->provider->getSupportedDomains(); + $this->assertEquals(['walla.co.il', 'walla.com'], $domains); + } +} From a7a4caae752efd4da65444c7e8deb2e0165fbec4 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sun, 19 Oct 2025 21:15:19 +0100 Subject: [PATCH 2/3] Remove deprecated getAddress method from Email class and update tests accordingly to use the new get method for email retrieval. --- src/Emails/Email.php | 8 -------- tests/EmailTest.php | 3 +-- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/src/Emails/Email.php b/src/Emails/Email.php index 2f06bfc..8c9383c 100644 --- a/src/Emails/Email.php +++ b/src/Emails/Email.php @@ -289,14 +289,6 @@ public function hasSubdomain(): bool return ! empty($this->domainInstance->getSub()); } - /** - * Get the email address (as provided, just lowercased and trimmed) - */ - public function getAddress(): string - { - return $this->email; - } - /** * Get the canonical email address by removing aliases and provider-specific variations * This method removes plus addressing, dot notation (for Gmail), and other aliasing techniques diff --git a/tests/EmailTest.php b/tests/EmailTest.php index c58e8bb..36092ee 100644 --- a/tests/EmailTest.php +++ b/tests/EmailTest.php @@ -26,7 +26,7 @@ public function test_valid_email(): void $this->assertEquals('company.org', $email->getProvider()); $this->assertEquals('', $email->getSubdomain()); $this->assertEquals(false, $email->hasSubdomain()); - $this->assertEquals('test@company.org', $email->getAddress()); + $this->assertEquals('test@company.org', $email->get()); } public function test_email_with_subdomain(): void @@ -154,7 +154,6 @@ public function test_email_normalization(): void $email = new Email(' USER@COMPANY.ORG '); $this->assertEquals('user@company.org', $email->get()); - $this->assertEquals('user@company.org', $email->getAddress()); } public function test_invalid_email_empty(): void From 458a83b77782fcfdf8247cbe6af60b8f98a28d29 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sun, 19 Oct 2025 21:16:56 +0100 Subject: [PATCH 3/3] Refactor WallaTest methods to use snake_case naming convention for improved consistency and readability. --- tests/Canonicals/Providers/WallaTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Canonicals/Providers/WallaTest.php b/tests/Canonicals/Providers/WallaTest.php index 272edbf..879d40f 100644 --- a/tests/Canonicals/Providers/WallaTest.php +++ b/tests/Canonicals/Providers/WallaTest.php @@ -14,7 +14,7 @@ protected function setUp(): void $this->provider = new Walla; } - public function testSupports(): void + public function test_supports(): void { $this->assertTrue($this->provider->supports('walla.co.il')); $this->assertTrue($this->provider->supports('walla.com')); @@ -24,7 +24,7 @@ public function testSupports(): void $this->assertFalse($this->provider->supports('example.com')); } - public function testGetCanonical(): void + public function test_get_canonical(): void { $testCases = [ // walla.co.il domain @@ -62,12 +62,12 @@ public function testGetCanonical(): void } } - public function testGetCanonicalDomain(): void + public function test_get_canonical_domain(): void { $this->assertEquals('walla.co.il', $this->provider->getCanonicalDomain()); } - public function testGetSupportedDomains(): void + public function test_get_supported_domains(): void { $domains = $this->provider->getSupportedDomains(); $this->assertEquals(['walla.co.il', 'walla.com'], $domains);