-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1b56999
commit f33de87
Showing
3 changed files
with
355 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
namespace Pop\Mail\Test\Transport; | ||
namespace Pop\Mail\Test\Client; | ||
|
||
use Pop\Http; | ||
use Pop\Mail\Client; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
<?php | ||
|
||
namespace Pop\Mail\Test\Client; | ||
|
||
use Pop\Http; | ||
use Pop\Mail\Client; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class GoogleTest extends TestCase | ||
{ | ||
|
||
public function testGetMessages1() | ||
{ | ||
$google = new Client\Google(); | ||
$google->createClient(__DIR__ . '/../tmp/my-google-app.json', '[email protected]'); | ||
$google->setToken('AUTH_TOKEN'); | ||
$google->setTokenExpires(time() + 1000); | ||
|
||
$this->expectException('DomainException'); | ||
$messages = $google->getMessages(); | ||
} | ||
|
||
public function testGetMessages2() | ||
{ | ||
$google = new Client\Google(); | ||
$google->createClient(__DIR__ . '/../tmp/my-google-app.json', '[email protected]'); | ||
$google->setToken('AUTH_TOKEN'); | ||
$google->setTokenExpires(time() + 1000); | ||
|
||
$search = [ | ||
'subject%' => 'Test', | ||
'%to' => '@outlook.com', | ||
'from' => '[email protected]', | ||
'sent>=' => '2023-10-01' | ||
]; | ||
|
||
$this->expectException('DomainException'); | ||
$messages = $google->getMessages('Inbox', $search, 25); | ||
} | ||
|
||
public function testGetMessages3() | ||
{ | ||
$google = new Client\Google(); | ||
$google->createClient(__DIR__ . '/../tmp/my-google-app.json', '[email protected]'); | ||
$google->setToken('AUTH_TOKEN'); | ||
$google->setTokenExpires(time() + 1000); | ||
|
||
$search = [ | ||
'subject' => 'Test', | ||
'to!=' => '[email protected]', | ||
'sent>' => '2023-10-01', | ||
'received<' => '2023-10-01', | ||
'date<=' => '2023-10-01', | ||
'unread' => true | ||
]; | ||
|
||
$this->expectException('DomainException'); | ||
$messages = $google->getMessages('Inbox', $search, 25); | ||
} | ||
|
||
public function testGetMessage() | ||
{ | ||
$google = new Client\Google(); | ||
$google->createClient(__DIR__ . '/../tmp/my-google-app.json', '[email protected]'); | ||
$google->setToken('AUTH_TOKEN'); | ||
$google->setTokenExpires(time() + 1000); | ||
|
||
$this->expectException('DomainException'); | ||
$message = $google->getMessage('123456789'); | ||
} | ||
|
||
public function testGetMessageRaw() | ||
{ | ||
$google = new Client\Google(); | ||
$google->createClient(__DIR__ . '/../tmp/my-google-app.json', '[email protected]'); | ||
$google->setToken('AUTH_TOKEN'); | ||
$google->setTokenExpires(time() + 1000); | ||
|
||
$this->expectException('DomainException'); | ||
$message = $google->getMessage('123456789', true); | ||
} | ||
|
||
public function testGetAttachments() | ||
{ | ||
$google = new Client\Google(); | ||
$google->createClient(__DIR__ . '/../tmp/my-google-app.json', '[email protected]'); | ||
$google->setToken('AUTH_TOKEN'); | ||
$google->setTokenExpires(time() + 1000); | ||
|
||
$this->expectException('DomainException'); | ||
$attachments = $google->getAttachments('123456789'); | ||
} | ||
|
||
public function testGetAttachment() | ||
{ | ||
$google = new Client\Google(); | ||
$google->createClient(__DIR__ . '/../tmp/my-google-app.json', '[email protected]'); | ||
$google->setToken('AUTH_TOKEN'); | ||
$google->setTokenExpires(time() + 1000); | ||
|
||
$this->expectException('DomainException'); | ||
$attachment = $google->getAttachment('123456789', '123456789'); | ||
} | ||
|
||
public function testMarkAsRead() | ||
{ | ||
$google = new Client\Google(); | ||
$google->createClient(__DIR__ . '/../tmp/my-google-app.json', '[email protected]'); | ||
$google->setToken('AUTH_TOKEN'); | ||
$google->setTokenExpires(time() + 1000); | ||
|
||
$this->expectException('DomainException'); | ||
$google->markAsRead('123456789'); | ||
} | ||
|
||
public function testMarkAsUnread() | ||
{ | ||
$google = new Client\Google(); | ||
$google->createClient(__DIR__ . '/../tmp/my-google-app.json', '[email protected]'); | ||
$google->setToken('AUTH_TOKEN'); | ||
$google->setTokenExpires(time() + 1000); | ||
|
||
$this->expectException('DomainException'); | ||
$google->markAsUnread('123456789'); | ||
} | ||
|
||
public function testGetMessagesException() | ||
{ | ||
$this->expectException('Pop\Mail\Client\Exception'); | ||
$google = new Client\Google(); | ||
$messages = $google->getMessages(); | ||
} | ||
|
||
public function testGetMessageException() | ||
{ | ||
$this->expectException('Pop\Mail\Client\Exception'); | ||
$google = new Client\Google(); | ||
$message = $google->getMessage('123456789'); | ||
} | ||
|
||
public function testGetAttachmentsException() | ||
{ | ||
$this->expectException('Pop\Mail\Client\Exception'); | ||
$google = new Client\Google(); | ||
$message = $google->getAttachments('123456789'); | ||
} | ||
|
||
public function testGetAttachmentException() | ||
{ | ||
$this->expectException('Pop\Mail\Client\Exception'); | ||
$google = new Client\Google(); | ||
$message = $google->getAttachment('123456789', '123456798'); | ||
} | ||
|
||
public function testMarkAsReadException() | ||
{ | ||
$this->expectException('Pop\Mail\Client\Exception'); | ||
$google = new Client\Google(); | ||
$google->markAsRead('123456789'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
<?php | ||
|
||
namespace Pop\Mail\Test\Client; | ||
|
||
use Pop\Http; | ||
use Pop\Mail\Client; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class Office365Test extends TestCase | ||
{ | ||
|
||
public function testGetMessages1() | ||
{ | ||
$office365 = new Client\Office365(); | ||
$office365->createClient(json_encode([ | ||
'client_id' => 'CLIENT_ID', | ||
'client_secret' => 'CLIENT_SECRET', | ||
'scope' => 'https://graph.microsoft.com/.default', | ||
'tenant_id' => 'TENANT_ID', | ||
'account_id' => 'ACCOUNT_ID', | ||
])); | ||
$office365->setToken('AUTH_TOKEN'); | ||
$office365->setTokenExpires(time() + 1000); | ||
|
||
$this->assertTrue(is_array($office365->getMessages())); | ||
} | ||
|
||
public function testGetMessages2() | ||
{ | ||
$office365 = new Client\Office365(); | ||
$office365->createClient(json_encode([ | ||
'client_id' => 'CLIENT_ID', | ||
'client_secret' => 'CLIENT_SECRET', | ||
'scope' => 'https://graph.microsoft.com/.default', | ||
'tenant_id' => 'TENANT_ID', | ||
'account_id' => 'ACCOUNT_ID', | ||
])); | ||
$office365->setToken('AUTH_TOKEN'); | ||
$office365->setTokenExpires(time() + 1000); | ||
|
||
$search = [ | ||
'subject%' => 'Test', | ||
'%to' => '@outlook.com', | ||
'from' => '[email protected]', | ||
'sent>=' => '2023-10-01' | ||
]; | ||
|
||
$this->assertTrue(is_array($office365->getMessages('Inbox', $search, 25))); | ||
} | ||
|
||
public function testGetMessages3() | ||
{ | ||
$office365 = new Client\Office365(); | ||
$office365->createClient(json_encode([ | ||
'client_id' => 'CLIENT_ID', | ||
'client_secret' => 'CLIENT_SECRET', | ||
'scope' => 'https://graph.microsoft.com/.default', | ||
'tenant_id' => 'TENANT_ID', | ||
'account_id' => 'ACCOUNT_ID', | ||
])); | ||
$office365->setToken('AUTH_TOKEN'); | ||
$office365->setTokenExpires(time() + 1000); | ||
|
||
$search = [ | ||
'subject' => 'Test', | ||
'to!=' => '[email protected]', | ||
'sent>' => '2023-10-01', | ||
'received<' => '2023-10-01', | ||
'date<=' => '2023-10-01', | ||
'unread' => true | ||
]; | ||
|
||
$this->assertTrue(is_array($office365->getMessages('Inbox', $search, 25))); | ||
} | ||
|
||
public function testGetMessage() | ||
{ | ||
$office365 = new Client\Office365(); | ||
$office365->createClient(json_encode([ | ||
'client_id' => 'CLIENT_ID', | ||
'client_secret' => 'CLIENT_SECRET', | ||
'scope' => 'https://graph.microsoft.com/.default', | ||
'tenant_id' => 'TENANT_ID', | ||
'account_id' => 'ACCOUNT_ID', | ||
])); | ||
$office365->setToken('AUTH_TOKEN'); | ||
$office365->setTokenExpires(time() + 1000); | ||
|
||
$this->assertTrue(is_array($office365->getMessage('123456789'))); | ||
} | ||
|
||
public function testGetMessageRaw() | ||
{ | ||
$office365 = new Client\Office365(); | ||
$office365->createClient(json_encode([ | ||
'client_id' => 'CLIENT_ID', | ||
'client_secret' => 'CLIENT_SECRET', | ||
'scope' => 'https://graph.microsoft.com/.default', | ||
'tenant_id' => 'TENANT_ID', | ||
'account_id' => 'ACCOUNT_ID', | ||
])); | ||
$office365->setToken('AUTH_TOKEN'); | ||
$office365->setTokenExpires(time() + 1000); | ||
|
||
$this->assertTrue(is_array($office365->getMessage('123456789', true))); | ||
} | ||
|
||
public function testGetAttachments() | ||
{ | ||
$office365 = new Client\Office365(); | ||
$office365->createClient(json_encode([ | ||
'client_id' => 'CLIENT_ID', | ||
'client_secret' => 'CLIENT_SECRET', | ||
'scope' => 'https://graph.microsoft.com/.default', | ||
'tenant_id' => 'TENANT_ID', | ||
'account_id' => 'ACCOUNT_ID', | ||
])); | ||
$office365->setToken('AUTH_TOKEN'); | ||
$office365->setTokenExpires(time() + 1000); | ||
|
||
$this->assertTrue(is_array($office365->getAttachments('123456789'))); | ||
} | ||
|
||
public function testGetAttachment() | ||
{ | ||
$office365 = new Client\Office365(); | ||
$office365->createClient(json_encode([ | ||
'client_id' => 'CLIENT_ID', | ||
'client_secret' => 'CLIENT_SECRET', | ||
'scope' => 'https://graph.microsoft.com/.default', | ||
'tenant_id' => 'TENANT_ID', | ||
'account_id' => 'ACCOUNT_ID', | ||
])); | ||
$office365->setToken('AUTH_TOKEN'); | ||
$office365->setTokenExpires(time() + 1000); | ||
|
||
$this->assertTrue(is_array($office365->getAttachment('123456789', '123456789'))); | ||
} | ||
|
||
public function testMarkAsRead() | ||
{ | ||
$office365 = new Client\Office365(); | ||
$office365->createClient(json_encode([ | ||
'client_id' => 'CLIENT_ID', | ||
'client_secret' => 'CLIENT_SECRET', | ||
'scope' => 'https://graph.microsoft.com/.default', | ||
'tenant_id' => 'TENANT_ID', | ||
'account_id' => 'ACCOUNT_ID', | ||
])); | ||
$office365->setToken('AUTH_TOKEN'); | ||
$office365->setTokenExpires(time() + 1000); | ||
|
||
$this->assertInstanceOf('Pop\Mail\Client\Office365', $office365->markAsRead('123456789')); | ||
$this->assertInstanceOf('Pop\Mail\Client\Office365', $office365->markAsUnread('123456789')); | ||
} | ||
|
||
public function testGetMessagesException() | ||
{ | ||
$this->expectException('Pop\Mail\Client\Exception'); | ||
$office365 = new Client\Office365(); | ||
$messages = $office365->getMessages(); | ||
} | ||
|
||
public function testGetMessageException() | ||
{ | ||
$this->expectException('Pop\Mail\Client\Exception'); | ||
$office365 = new Client\Office365(); | ||
$message = $office365->getMessage('123456789'); | ||
} | ||
|
||
public function testGetAttachmentsException() | ||
{ | ||
$this->expectException('Pop\Mail\Client\Exception'); | ||
$office365 = new Client\Office365(); | ||
$message = $office365->getAttachments('123456789'); | ||
} | ||
|
||
public function testGetAttachmentException() | ||
{ | ||
$this->expectException('Pop\Mail\Client\Exception'); | ||
$office365 = new Client\Office365(); | ||
$message = $office365->getAttachment('123456789', '123456798'); | ||
} | ||
|
||
public function testMarkAsReadException() | ||
{ | ||
$this->expectException('Pop\Mail\Client\Exception'); | ||
$office365 = new Client\Office365(); | ||
$office365->markAsRead('123456789'); | ||
} | ||
|
||
} |