Skip to content

Commit

Permalink
Updated to support PHP 7.2+
Browse files Browse the repository at this point in the history
  • Loading branch information
jm-mailosaur committed Aug 18, 2019
1 parent 020047f commit b0087cd
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 24 deletions.
1 change: 1 addition & 0 deletions .phpunit.result.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C:37:"PHPUnit\Runner\DefaultTestResultCache":1959:{a:2:{s:7:"defects";a:17:{s:34:"MailosaurTest\EmailsTests::testGet";i:4;s:42:"MailosaurTest\EmailsTests::testGetNotFound";i:4;s:38:"MailosaurTest\EmailsTests::testWaitFor";i:4;s:52:"MailosaurTest\EmailsTests::testSearchNoCriteriaError";i:4;s:45:"MailosaurTest\EmailsTests::testSearchBySentTo";i:4;s:57:"MailosaurTest\EmailsTests::testSearchBySentToInvalidEmail";i:4;s:43:"MailosaurTest\EmailsTests::testSearchByBody";i:4;s:46:"MailosaurTest\EmailsTests::testSearchBySubject";i:4;s:43:"MailosaurTest\EmailsTests::testSpamAnalysis";i:4;s:37:"MailosaurTest\EmailsTests::testDelete";i:4;s:34:"MailosaurTest\EmailsTests::testAll";i:4;s:38:"MailosaurTest\FilesTests::testGetEmail";i:6;s:43:"MailosaurTest\FilesTests::testGetAttachment";i:4;s:36:"Mailosaur_Test\ServersTests::testAll";i:4;s:44:"Mailosaur_Test\ServersTests::testGetNotFound";i:4;s:37:"Mailosaur_Test\ServersTests::testCrud";i:4;s:45:"Mailosaur_Test\ServersTests::testFailedCreate";i:4;}s:5:"times";a:17:{s:34:"MailosaurTest\EmailsTests::testGet";d:12.197;s:42:"MailosaurTest\EmailsTests::testGetNotFound";d:13.847;s:38:"MailosaurTest\EmailsTests::testWaitFor";d:12.91;s:52:"MailosaurTest\EmailsTests::testSearchNoCriteriaError";d:11.678;s:45:"MailosaurTest\EmailsTests::testSearchBySentTo";d:13.659;s:57:"MailosaurTest\EmailsTests::testSearchBySentToInvalidEmail";d:11.37;s:43:"MailosaurTest\EmailsTests::testSearchByBody";d:11.884;s:46:"MailosaurTest\EmailsTests::testSearchBySubject";d:14.378;s:43:"MailosaurTest\EmailsTests::testSpamAnalysis";d:15.667;s:37:"MailosaurTest\EmailsTests::testDelete";d:13.786;s:34:"MailosaurTest\EmailsTests::testAll";d:16.943;s:38:"MailosaurTest\FilesTests::testGetEmail";d:5.483;s:43:"MailosaurTest\FilesTests::testGetAttachment";d:5.167;s:36:"Mailosaur_Test\ServersTests::testAll";d:0.302;s:44:"Mailosaur_Test\ServersTests::testGetNotFound";d:0.404;s:37:"Mailosaur_Test\ServersTests::testCrud";d:5.715;s:45:"Mailosaur_Test\ServersTests::testFailedCreate";d:0.283;}}}
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
}
},
"require-dev": {
"phpunit/phpunit": "^7",
"nette/utils": "v2.3",
"nette/mail": "v2.3.5"
"phpunit/phpunit": "^8",
"nette/utils": "v3.0.1",
"nette/mail": "v3.1.0"
},
"keywords": [
"email",
Expand All @@ -25,7 +25,7 @@
"automation"
],
"require": {
"php": ">=7.1"
"php": ">=7.2"
},
"license": "MIT",
"authors": [
Expand Down
9 changes: 6 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
</testsuite>
</testsuites>
<filter>
<blacklist>
<directory suffix=".php">/vendor</directory>
</blacklist>
<whitelist>
<directory suffix=".php">src</directory>
<exclude>
<directory suffix=".php">/vendor</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
14 changes: 7 additions & 7 deletions tests/EmailsTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Mailosaur\Models\MessageSummary;
use Mailosaur\Models\SearchCriteria;

class EmailsTests extends \PHPUnit_Framework_TestCase
class EmailsTests extends \PHPUnit\Framework\TestCase
{
/** @var \Mailosaur\MailosaurClient
*/
Expand All @@ -21,9 +21,9 @@ class EmailsTests extends \PHPUnit_Framework_TestCase
public $emails;


public function setUp()
public function setUp(): void
{
$baseUrl = ($h = getenv('MAILOSAUR_BASE_URL')) ? $h : 'https://mailosaur.com';
$baseUrl = ($h = getenv('MAILOSAUR_BASE_URL')) ? $h : 'https://mailosaur.com/';
$apiKey = getenv('MAILOSAUR_API_KEY');
$this->server = getenv('MAILOSAUR_SERVER');

Expand Down Expand Up @@ -52,7 +52,7 @@ public function testGet()

public function testGetNotFound()
{
$this->setExpectedException('\Mailosaur\Models\MailosaurException');
$this->expectException(\Mailosaur\Models\MailosaurException::class);
$this->client->messages->get(uniqid());
}

Expand All @@ -73,7 +73,7 @@ public function testWaitFor()

public function testSearchNoCriteriaError()
{
$this->setExpectedException('\Mailosaur\Models\MailosaurException');
$this->expectException(\Mailosaur\Models\MailosaurException::class);
$this->client->messages->search($this->server, new SearchCriteria());
}

Expand All @@ -94,7 +94,7 @@ public function testSearchBySentTo()

public function testSearchBySentToInvalidEmail()
{
$this->setExpectedException('\Mailosaur\Models\MailosaurException');
$this->expectException(\Mailosaur\Models\MailosaurException::class);

$criteria = new SearchCriteria();
$criteria->sentTo = '.not_an_email_address';
Expand Down Expand Up @@ -147,7 +147,7 @@ public function testDelete()

$this->client->messages->delete($targetEmailId);

$this->setExpectedException('\Mailosaur\Models\MailosaurException');
$this->expectException(\Mailosaur\Models\MailosaurException::class);

$this->client->messages->delete($targetEmailId);
}
Expand Down
8 changes: 4 additions & 4 deletions tests/FilesTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Mailosaur\MailosaurClient;
use Mailosaur\Models\SearchCriteria;

class FilesTests extends \PHPUnit_Framework_TestCase
class FilesTests extends \PHPUnit\Framework\TestCase
{
/** @var \Mailosaur\MailosaurClient */
public $client;
Expand All @@ -17,9 +17,9 @@ class FilesTests extends \PHPUnit_Framework_TestCase
/** @var \Mailosaur\Models\Message */
public $email;

public function setUp()
public function setUp(): void
{
$baseUrl = ($h = getenv('MAILOSAUR_BASE_URL')) ? $h : 'https://mailosaur.com';
$baseUrl = ($h = getenv('MAILOSAUR_BASE_URL')) ? $h : 'https://mailosaur.com/';
$apiKey = getenv('MAILOSAUR_API_KEY');
$this->server = getenv('MAILOSAUR_SERVER');

Expand Down Expand Up @@ -48,7 +48,7 @@ public function testGetEmail()

$this->assertNotNull($result);
$this->assertTrue(strlen($result) > 0);
$this->assertContains($this->email->subject, $result);
$this->assertStringContainsString($this->email->subject, $result);
}

public function testGetAttachment()
Expand Down
13 changes: 7 additions & 6 deletions tests/ServersTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
use Mailosaur\MailosaurClient;
use Mailosaur\Models\ServerCreateOptions;

class ServersTests extends \PHPUnit_Framework_TestCase
class ServersTests extends \PHPUnit\Framework\TestCase
{
/** @var \Mailosaur\MailosaurClient */
public $mClient;

public function setUp()
public function setUp(): void
{
$baseUrl = ($h = getenv('MAILOSAUR_BASE_URL')) ? $h : 'https://mailosaur.com';
$baseUrl = ($h = getenv('MAILOSAUR_BASE_URL')) ? $h : 'https://mailosaur.com/';
$apiKey = getenv('MAILOSAUR_API_KEY');

if (empty($apiKey)) {
Expand All @@ -32,7 +32,7 @@ public function testAll()

public function testGetNotFound()
{
$this->setExpectedException('\Mailosaur\Models\MailosaurException');
$this->expectException(\Mailosaur\Models\MailosaurException::class);

$this->mClient->servers->get("efe907e9-74ed-4113-a3e0-a3d41d914765");
}
Expand Down Expand Up @@ -75,15 +75,16 @@ public function testCrud()

$this->mClient->servers->delete($retrievedServer->id);

$this->setExpectedException('\Mailosaur\Models\MailosaurException');
$this->expectException(\Mailosaur\Models\MailosaurException::class);
$this->mClient->servers->delete($retrievedServer->id);
}

public function testFailedCreate()
{
$options = new ServerCreateOptions();

$this->setExpectedException('\Mailosaur\Models\MailosaurException', "Operation returned an invalid status code 'Bad Request'", 400);
$this->expectException(\Mailosaur\Models\MailosaurException::class);
$this->expectExceptionMessage("Operation returned an invalid status code 'Bad Request'");

$this->mClient->servers->create($options);
}
Expand Down

0 comments on commit b0087cd

Please sign in to comment.