Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tests/Messaging/Adapter/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ protected function getLastEmail(): array
*/
protected function assertResponse(array $response): void
{
$this->assertEquals(1, $response['deliveredTo'], \var_export($response, true));
$this->assertEquals('', $response['results'][0]['error'], \var_export($response, true));
$this->assertEquals('success', $response['results'][0]['status'], \var_export($response, true));
$this->assertSame(1, $response['deliveredTo'], \var_export($response, true));
$this->assertSame('', $response['results'][0]['error'], \var_export($response, true));
$this->assertSame('success', $response['results'][0]['status'], \var_export($response, true));
}
}
2 changes: 1 addition & 1 deletion tests/Messaging/Adapter/Chat/DiscordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ public function testWebhookIDExtraction(): void
$property = $reflector->getProperty('webhookId');
$property->setAccessible(true);

$this->assertEquals($webhookId, $property->getValue($discord), 'Webhook ID was not correctly extracted');
$this->assertSame($webhookId, $property->getValue($discord), 'Webhook ID was not correctly extracted');
}
}
14 changes: 7 additions & 7 deletions tests/Messaging/Adapter/Email/EmailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ public function testSendEmail(): void
$lastEmail = $this->getLastEmail();

$this->assertResponse($response);
$this->assertEquals($to, $lastEmail['to'][0]['address']);
$this->assertEquals($fromEmail, $lastEmail['from'][0]['address']);
$this->assertEquals($fromName, $lastEmail['from'][0]['name']);
$this->assertEquals($subject, $lastEmail['subject']);
$this->assertEquals($content, \trim($lastEmail['text']));
$this->assertEquals($cc[0]['email'], $lastEmail['cc'][0]['address']);
$this->assertEquals($bcc[0]['email'], $lastEmail['envelope']['to'][2]['address']);
$this->assertSame($to, $lastEmail['to'][0]['address']);
$this->assertSame($fromEmail, $lastEmail['from'][0]['address']);
$this->assertSame($fromName, $lastEmail['from'][0]['name']);
$this->assertSame($subject, $lastEmail['subject']);
$this->assertSame($content, \trim($lastEmail['text']));
$this->assertSame($cc[0]['email'], $lastEmail['cc'][0]['address']);
$this->assertSame($bcc[0]['email'], $lastEmail['envelope']['to'][2]['address']);
}
}
10 changes: 5 additions & 5 deletions tests/Messaging/Adapter/Email/ResendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ public function testSendMultipleEmails(): void

$response = $this->sender->send($message);

$this->assertEquals(2, $response['deliveredTo'], \var_export($response, true));
$this->assertEquals('', $response['results'][0]['error'], \var_export($response, true));
$this->assertEquals('success', $response['results'][0]['status'], \var_export($response, true));
$this->assertEquals('', $response['results'][1]['error'], \var_export($response, true));
$this->assertEquals('success', $response['results'][1]['status'], \var_export($response, true));
$this->assertSame(2, $response['deliveredTo'], \var_export($response, true));
$this->assertSame('', $response['results'][0]['error'], \var_export($response, true));
$this->assertSame('success', $response['results'][0]['status'], \var_export($response, true));
$this->assertSame('', $response['results'][1]['error'], \var_export($response, true));
$this->assertSame('success', $response['results'][1]['status'], \var_export($response, true));
}

public function testSendEmailWithAttachmentsThrowsException(): void
Expand Down
22 changes: 11 additions & 11 deletions tests/Messaging/Adapter/Email/SMTPTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public function testSendEmail(): void
$lastEmail = $this->getLastEmail();

$this->assertResponse($response);
$this->assertEquals($to, $lastEmail['to'][0]['address']);
$this->assertEquals($fromEmail, $lastEmail['from'][0]['address']);
$this->assertEquals($subject, $lastEmail['subject']);
$this->assertEquals($content, \trim($lastEmail['text']));
$this->assertSame($to, $lastEmail['to'][0]['address']);
$this->assertSame($fromEmail, $lastEmail['from'][0]['address']);
$this->assertSame($subject, $lastEmail['subject']);
$this->assertSame($content, \trim($lastEmail['text']));
}

public function testSendEmailWithAttachment(): void
Expand Down Expand Up @@ -72,10 +72,10 @@ public function testSendEmailWithAttachment(): void
$lastEmail = $this->getLastEmail();

$this->assertResponse($response);
$this->assertEquals($to, $lastEmail['to'][0]['address']);
$this->assertEquals($fromEmail, $lastEmail['from'][0]['address']);
$this->assertEquals($subject, $lastEmail['subject']);
$this->assertEquals($content, \trim($lastEmail['text']));
$this->assertSame($to, $lastEmail['to'][0]['address']);
$this->assertSame($fromEmail, $lastEmail['from'][0]['address']);
$this->assertSame($subject, $lastEmail['subject']);
$this->assertSame($content, \trim($lastEmail['text']));
}

public function testSendEmailOnlyBCC(): void
Expand Down Expand Up @@ -110,8 +110,8 @@ public function testSendEmailOnlyBCC(): void
$lastEmail = $this->getLastEmail();

$this->assertResponse($response);
$this->assertEquals($fromEmail, $lastEmail['from'][0]['address']);
$this->assertEquals($subject, $lastEmail['subject']);
$this->assertEquals($content, \trim($lastEmail['text']));
$this->assertSame($fromEmail, $lastEmail['from'][0]['address']);
$this->assertSame($subject, $lastEmail['subject']);
$this->assertSame($content, \trim($lastEmail['text']));
}
}
12 changes: 6 additions & 6 deletions tests/Messaging/Adapter/SMS/GEOSMS/CallingCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ class CallingCodeTest extends Base
{
public function testFromPhoneNumber(): void
{
$this->assertEquals(CallingCode::NORTH_AMERICA, CallingCode::fromPhoneNumber('+11234567890'));
$this->assertEquals(CallingCode::INDIA, CallingCode::fromPhoneNumber('+911234567890'));
$this->assertEquals(CallingCode::ISRAEL, CallingCode::fromPhoneNumber('9721234567890'));
$this->assertEquals(CallingCode::UNITED_ARAB_EMIRATES, CallingCode::fromPhoneNumber('009711234567890'));
$this->assertEquals(CallingCode::UNITED_KINGDOM, CallingCode::fromPhoneNumber('011441234567890'));
$this->assertEquals(null, CallingCode::fromPhoneNumber('2'));
$this->assertSame(CallingCode::NORTH_AMERICA, CallingCode::fromPhoneNumber('+11234567890'));
$this->assertSame(CallingCode::INDIA, CallingCode::fromPhoneNumber('+911234567890'));
$this->assertSame(CallingCode::ISRAEL, CallingCode::fromPhoneNumber('9721234567890'));
$this->assertSame(CallingCode::UNITED_ARAB_EMIRATES, CallingCode::fromPhoneNumber('009711234567890'));
$this->assertSame(CallingCode::UNITED_KINGDOM, CallingCode::fromPhoneNumber('011441234567890'));
$this->assertSame(null, CallingCode::fromPhoneNumber('2'));
}
}
18 changes: 9 additions & 9 deletions tests/Messaging/Adapter/SMS/GEOSMSTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public function testSendSMSUsingDefaultAdapter(): void

$result = $adapter->send($message);

$this->assertEquals(1, count($result));
$this->assertEquals('success', $result['default']['results'][0]['status']);
$this->assertSame(1, count($result));
$this->assertSame('success', $result['default']['results'][0]['status']);
}

public function testSendSMSUsingLocalAdapter(): void
Expand All @@ -54,8 +54,8 @@ public function testSendSMSUsingLocalAdapter(): void

$result = $adapter->send($message);

$this->assertEquals(1, count($result));
$this->assertEquals('success', $result['local']['results'][0]['status']);
$this->assertSame(1, count($result));
$this->assertSame('success', $result['local']['results'][0]['status']);
}

public function testSendSMSUsingLocalAdapterAndDefault(): void
Expand All @@ -81,9 +81,9 @@ public function testSendSMSUsingLocalAdapterAndDefault(): void

$result = $adapter->send($message);

$this->assertEquals(2, count($result));
$this->assertEquals('success', $result['local']['results'][0]['status']);
$this->assertEquals('success', $result['default']['results'][0]['status']);
$this->assertSame(2, count($result));
$this->assertSame('success', $result['local']['results'][0]['status']);
$this->assertSame('success', $result['default']['results'][0]['status']);
}

public function testSendSMSUsingGroupedLocalAdapter(): void
Expand All @@ -108,7 +108,7 @@ public function testSendSMSUsingGroupedLocalAdapter(): void

$result = $adapter->send($message);

$this->assertEquals(1, count($result));
$this->assertEquals('success', $result['local']['results'][0]['status']);
$this->assertSame(1, count($result));
$this->assertSame('success', $result['local']['results'][0]['status']);
}
}
18 changes: 9 additions & 9 deletions tests/Messaging/Adapter/SMS/SMSTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ public function testSendSMS(): void

$smsRequest = $this->getLastRequest();

$this->assertEquals('http://request-catcher:5000/mock-sms', $smsRequest['url']);
$this->assertEquals('Appwrite Mock Message Sender', $smsRequest['headers']['User-Agent']);
$this->assertEquals('username', $smsRequest['headers']['X-Username']);
$this->assertEquals('password', $smsRequest['headers']['X-Key']);
$this->assertEquals('POST', $smsRequest['method']);
$this->assertEquals('+987654321', $smsRequest['data']['from']);
$this->assertEquals('+123456789', $smsRequest['data']['to']);
$this->assertEquals(98, $sender->getCountryCode($smsRequest['data']['from']));
$this->assertEquals(1, $sender->getCountryCode($smsRequest['data']['to']));
$this->assertSame('http://request-catcher:5000/mock-sms', $smsRequest['url']);
$this->assertSame('Appwrite Mock Message Sender', $smsRequest['headers']['User-Agent']);
$this->assertSame('username', $smsRequest['headers']['X-Username']);
$this->assertSame('password', $smsRequest['headers']['X-Key']);
$this->assertSame('POST', $smsRequest['method']);
$this->assertSame('+987654321', $smsRequest['data']['from']);
$this->assertSame('+123456789', $smsRequest['data']['to']);
$this->assertSame(98, $sender->getCountryCode($smsRequest['data']['from']));
$this->assertSame(1, $sender->getCountryCode($smsRequest['data']['to']));
}
}
4 changes: 2 additions & 2 deletions tests/Messaging/Adapter/SMS/TelnyxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public function testSendSMS(): void
// );

// $result = $sender->send($message);

// $this->assertEquals('success', $result["type"]);
//
// $this->assertSame('success', $result["type"]);

$this->markTestSkipped('Telnyx had no testing numbers available at this time.');
}
Expand Down
Loading