Skip to content
This repository was archived by the owner on Apr 8, 2024. It is now read-only.

Commit dd49bff

Browse files
committed
Allowing test to work in both 5.x & 7
1 parent 4b4ffe4 commit dd49bff

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

tests/MailRecorderTest.php

+22-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
namespace Spinen\MailAssertions;
44

55
use Mockery;
6+
use PHPUnit_Framework_Error;
67
use PHPUnit_Framework_TestCase;
78
use StdClass;
89
use Swift_Events_SendEvent;
10+
use TypeError;
911

1012
/**
1113
* Class MailRecorderTest
@@ -32,7 +34,16 @@ public function it_can_be_constructed()
3234
*/
3335
public function it_cannot_be_constructed_without_a_PHPUnit_Framework_TestCase()
3436
{
35-
new MailRecorder();
37+
if (class_exists(TypeError::class)) {
38+
try {
39+
new MailRecorder();
40+
} catch (TypeError $e) {
41+
throw new PHPUnit_Framework_Error('Argument 1 passed to method must be an array, but not', 0,
42+
$e->getFile(), $e->getLine());
43+
}
44+
} else {
45+
new MailRecorder();
46+
}
3647
}
3748

3849
/**
@@ -42,7 +53,16 @@ public function it_cannot_be_constructed_without_a_PHPUnit_Framework_TestCase()
4253
*/
4354
public function it_cannot_be_constructed_with_class_other_than_a_PHPUnit_Framework_TestCase()
4455
{
45-
new MailRecorder(new StdClass());
56+
if (class_exists(TypeError::class)) {
57+
try {
58+
new MailRecorder(new StdClass());
59+
} catch (TypeError $e) {
60+
throw new PHPUnit_Framework_Error('Argument 1 passed to method must be an array, but not', 0,
61+
$e->getFile(), $e->getLine());
62+
}
63+
} else {
64+
new MailRecorder(new StdClass());
65+
}
4666
}
4767

4868
/**

0 commit comments

Comments
 (0)