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

Commit 5a31619

Browse files
committed
Support PHPUnit 5 and 6
1 parent 24aa711 commit 5a31619

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"rmccue/requests": ">=1.0"
3333
},
3434
"require-dev": {
35-
"phpunit/phpunit": "~4.0",
35+
"phpunit/phpunit": "~4.8.35 || ^5.7 || ^6.4",
3636
"codacy/coverage": "dev-master"
3737
},
3838
"autoload": {

tests/MoipTest.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ public function testShouldRaiseValidationException()
108108

109109
/**
110110
* MoipTest if \Moip\Exceptios\UnautorizedException is thrown.
111+
*
112+
* @expectedException Moip\Exceptions\UnautorizedException
111113
*/
112114
public function testShouldRaiseUnautorizedException()
113115
{
@@ -116,14 +118,15 @@ public function testShouldRaiseUnautorizedException()
116118

117119
return;
118120
}
119-
$this->setExpectedException('\Moip\Exceptions\UnautorizedException');
120121
$body = '{ "ERROR" : "Token or Key are invalids" }'; // the body is not processed in any way, i'm putting this for completeness
121122
$this->mockHttpSession($body, 401);
122123
$this->moip->orders()->get('ORD-1AWC30TWYZMX');
123124
}
124125

125126
/**
126127
* MoipTest if UnexpectedException is thrown when 500 http status code is returned.
128+
*
129+
* @expectedException Moip\Exceptions\UnexpectedException
127130
*/
128131
public function testShouldRaiseUnexpectedException500()
129132
{
@@ -132,7 +135,6 @@ public function testShouldRaiseUnexpectedException500()
132135

133136
return;
134137
}
135-
$this->setExpectedException('\Moip\Exceptions\UnexpectedException');
136138
$this->mockHttpSession('error', 500); // the body isn't processed
137139
$this->moip->orders()->get('ORD-1AWC30TWYZMX');
138140
}
@@ -147,7 +149,7 @@ public function testShouldRaiseUnexpectedExceptionNetworkError()
147149

148150
return;
149151
}
150-
$sess = $this->getMock('\Requests_Session');
152+
$sess = $this->getMockBuilder('\Requests_Session')->getMock();
151153
$sess->expects($this->once())->method('request')->willThrowException(new Requests_Exception('test error',
152154
'test'));
153155
$this->moip->setSession($sess);

tests/Resource/RefundTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ private function paymentBoleto($returnPayment = true)
204204
$order = $this->createOrder()->create();
205205
$this->mockHttpSession($this->body_billet_pay);
206206
$payment = $order->payments()
207-
->setBoleto(new \DateTime('today +1day'),'http://dev.moip.com.br/images/logo-header-moip.png')
207+
->setBoleto(new \DateTime('today +1day'), 'http://dev.moip.com.br/images/logo-header-moip.png')
208208
->execute();
209209
$this->mockHttpSession('');
210210
$payment->authorize();

tests/TestCase.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
use Moip\Moip;
77
use Moip\Resource\Customer;
88
use Moip\Resource\Orders;
9-
use PHPUnit_Framework_TestCase;
9+
use PHPUnit\Framework\TestCase as BaseTestCase;
1010
use Requests_Response;
1111

1212
/**
1313
* class TestCase.
1414
*/
15-
abstract class TestCase extends PHPUnit_Framework_TestCase
15+
abstract class TestCase extends BaseTestCase
1616
{
1717
/**
1818
* Variables representing the test modes. On MOCK mode no http request will be made.
@@ -254,7 +254,7 @@ public function setUp()
254254
$auth = new OAuth($moip_access_token);
255255
} else {
256256
$this->sandbox_mock = self::MOCK;
257-
$auth = $this->getMock('\Moip\Contracts\Authentication');
257+
$auth = $this->getMockBuilder('\Moip\Contracts\Authentication')->getMock();
258258
}
259259
$this->moip = new Moip($auth, Moip::ENDPOINT_SANDBOX);
260260
}
@@ -285,7 +285,7 @@ public function mockHttpSession($body, $status_code = 200)
285285
$resp = new Requests_Response();
286286
$resp->body = $body;
287287
$resp->status_code = $status_code;
288-
$sess = $this->getMock('\Requests_Session');
288+
$sess = $this->getMockBuilder('\Requests_Session')->getMock();
289289
$sess->expects($this->once())->method('request')->willReturn($resp);
290290
$this->moip->setSession($sess);
291291
}

0 commit comments

Comments
 (0)