Skip to content

Commit 0506449

Browse files
committed
Fix old phpunit annotations
1 parent 3529d89 commit 0506449

File tree

5 files changed

+69
-92
lines changed

5 files changed

+69
-92
lines changed

tests/Common/CreditCardTest.php

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -59,60 +59,55 @@ public function testValidateFixture()
5959
$this->card->validate();
6060
}
6161

62-
/**
63-
* @expectedException \Omnipay\Common\Exception\InvalidCreditCardException
64-
* @expectedExceptionMessage The credit card number is required
65-
*/
6662
public function testValidateNumberRequired()
6763
{
64+
$this->expectException(\Omnipay\Common\Exception\InvalidCreditCardException::class);
65+
$this->expectExceptionMessage('The credit card number is required');
66+
6867
$this->card->setNumber(null);
6968
$this->card->validate();
7069
}
7170

72-
/**
73-
* @expectedException \Omnipay\Common\Exception\InvalidCreditCardException
74-
* @expectedExceptionMessage The expiration month is required
75-
*/
7671
public function testValidateExpiryMonthRequired()
7772
{
73+
$this->expectException(\Omnipay\Common\Exception\InvalidCreditCardException::class);
74+
$this->expectExceptionMessage('The expiration month is required');
75+
7876
$this->card->setExpiryMonth(null);
7977
$this->card->validate();
8078
}
8179

82-
/**
83-
* @expectedException \Omnipay\Common\Exception\InvalidCreditCardException
84-
* @expectedExceptionMessage The expiration year is required
85-
*/
8680
public function testValidateExpiryYearRequired()
8781
{
82+
$this->expectException(\Omnipay\Common\Exception\InvalidCreditCardException::class);
83+
$this->expectExceptionMessage('The expiration year is required');
84+
8885
$this->card->setExpiryYear(null);
8986
$this->card->validate();
9087
}
9188

92-
/**
93-
* @expectedException \Omnipay\Common\Exception\InvalidCreditCardException
94-
* @expectedExceptionMessage Card has expired
95-
*/
9689
public function testValidateExpiryDate()
9790
{
91+
$this->expectException(\Omnipay\Common\Exception\InvalidCreditCardException::class);
92+
$this->expectExceptionMessage('Card has expired');
93+
9894
$this->card->setExpiryYear(gmdate('Y')-1);
9995
$this->card->validate();
10096
}
10197

102-
/**
103-
* @expectedException \Omnipay\Common\Exception\InvalidCreditCardException
104-
* @expectedExceptionMessage Card number is invalid
105-
*/
10698
public function testValidateNumber()
10799
{
100+
$this->expectException(\Omnipay\Common\Exception\InvalidCreditCardException::class);
101+
$this->expectExceptionMessage('Card number is invalid');
102+
108103
$this->card->setNumber('4111111111111110');
109104
$this->card->validate();
110105
}
111106

112107
public function testGetSupportedBrands()
113108
{
114109
$brands = $this->card->getSupportedBrands();
115-
$this->assertInternalType('array', $brands);
110+
$this->assertIsArray($brands);
116111
$this->assertArrayHasKey(CreditCard::BRAND_VISA, $brands);
117112
}
118113

@@ -671,22 +666,20 @@ public function testGender()
671666
$this->assertEquals('female', $this->card->getGender());
672667
}
673668

674-
/**
675-
* @expectedException Omnipay\Common\Exception\InvalidCreditCardException
676-
* @expectedExceptionMessage Card number is invalid
677-
*/
678669
public function testInvalidLuhn()
679670
{
671+
$this->expectException(\Omnipay\Common\Exception\InvalidCreditCardException::class);
672+
$this->expectExceptionMessage('Card number is invalid');
673+
680674
$this->card->setNumber('43');
681675
$this->card->validate();
682676
}
683677

684-
/**
685-
* @expectedException Omnipay\Common\Exception\InvalidCreditCardException
686-
* @expectedExceptionMessage Card number should have 12 to 19 digits
687-
*/
688678
public function testInvalidShortCard()
689679
{
680+
$this->expectException(\Omnipay\Common\Exception\InvalidCreditCardException::class);
681+
$this->expectExceptionMessage('Card number should have 12 to 19 digits');
682+
690683
$this->card->setNumber('4440');
691684
$this->card->validate();
692685
}

tests/Common/GatewayFactoryTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,11 @@ public function testCreateFullyQualified()
5353
$this->assertInstanceOf('\\Omnipay\\SpareChange\\TestGateway', $gateway);
5454
}
5555

56-
/**
57-
* @expectedException \Omnipay\Common\Exception\RuntimeException
58-
* @expectedExceptionMessage Class '\Omnipay\Invalid\Gateway' not found
59-
*/
6056
public function testCreateInvalid()
6157
{
58+
$this->expectException(\Omnipay\Common\Exception\RuntimeException::class);
59+
$this->expectExceptionMessage("Class '\Omnipay\Invalid\Gateway' not found");
60+
6261
$gateway = $this->factory->create('Invalid');
6362
}
6463
}

tests/Common/Http/ClientTest.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@
1313

1414
class ClientTest extends TestCase
1515
{
16-
public function testEmptyConstruct()
17-
{
18-
$client = new Client();
19-
20-
$this->assertAttributeInstanceOf(HttpClient::class, 'httpClient', $client);
21-
$this->assertAttributeInstanceOf(RequestFactory::class, 'requestFactory', $client);
22-
}
2316

2417
public function testSend()
2518
{

tests/Common/Message/AbstractRequestTest.php

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ public function testInitializeWithParams()
4848
$this->assertSame('1.23', $this->request->getAmount());
4949
}
5050

51-
/**
52-
* @expectedException \Omnipay\Common\Exception\RuntimeException
53-
* @expectedExceptionMessage Request cannot be modified after it has been sent!
54-
*/
5551
public function testInitializeAfterRequestSent()
5652
{
53+
$this->expectException(\Omnipay\Common\Exception\RuntimeException::class);
54+
$this->expectExceptionMessage("Request cannot be modified after it has been sent!");
55+
56+
5757
$this->request = new AbstractRequestTest_MockAbstractRequest($this->getHttpClient(), $this->getHttpRequest());
5858
$this->request->send();
5959

@@ -120,12 +120,11 @@ public function testAmountZeroString()
120120
$this->assertSame('0.00', $this->request->getAmount());
121121
}
122122

123-
/**
124-
* @expectedException \Omnipay\Common\Exception\InvalidRequestException
125-
* @expectedExceptionMessage A zero amount is not allowed.
126-
*/
127123
public function testAmountZeroNotAllowed()
128124
{
125+
$this->expectException(\Omnipay\Common\Exception\InvalidRequestException::class);
126+
$this->expectExceptionMessage('A zero amount is not allowed.');
127+
129128
$this->changeProtectedProperty('zeroAmountAllowed', false);
130129
$this->request->setAmount('0.00');
131130
$this->request->getAmount();
@@ -164,13 +163,14 @@ public function testAmountPrecisionLargeNumbers()
164163
}
165164

166165
/**
167-
* @expectedException \Omnipay\Common\Exception\InvalidRequestException
168166
*
169167
* We still want to catch obvious fractions of the minor units that are
170168
* not precision errors at a much lower level.
171169
*/
172170
public function testAmountPrecisionTooHigh()
173171
{
172+
$this->expectException(\Omnipay\Common\Exception\InvalidRequestException::class);
173+
174174
$this->assertSame($this->request, $this->request->setAmount('123.005'));
175175
$this->assertSame('123.005', $this->request->getAmount());
176176
}
@@ -182,11 +182,10 @@ public function testGetAmountNoDecimals()
182182
$this->assertSame('1366', $this->request->getAmount());
183183
}
184184

185-
/**
186-
* @expectedException \Omnipay\Common\Exception\InvalidRequestException
187-
*/
188185
public function testGetAmountNoDecimalsRounding()
189186
{
187+
$this->expectException(\Omnipay\Common\Exception\InvalidRequestException::class);
188+
190189
// There will not be any rounding; the amount is sent as requested or not at all.
191190
$this->assertSame($this->request, $this->request->setAmount('136.5'));
192191
$this->assertSame($this->request, $this->request->setCurrency('JPY'));
@@ -219,11 +218,10 @@ public function testGetAmountIntegerNoDecimals()
219218
$this->assertSame(1366, $this->request->getAmountInteger());
220219
}
221220

222-
/**
223-
* @expectedException \InvalidArgumentException
224-
*/
225221
public function testAmountThousandsSepThrowsException()
226222
{
223+
$this->expectException(\InvalidArgumentException::class);
224+
227225
$this->assertSame($this->request, $this->request->setAmount('1,234.00'));
228226
$this->request->getAmount();
229227
}
@@ -233,24 +231,24 @@ public function testAmountThousandsSepThrowsException()
233231
*/
234232
public function testAmountInvalidFormatThrowsException()
235233
{
234+
$this->expectException(\InvalidArgumentException::class);
235+
236236
$this->assertSame($this->request, $this->request->setAmount('1.234.00'));
237237
$this->request->getAmount();
238238
}
239239

240-
/**
241-
* @expectedException \Omnipay\Common\Exception\InvalidRequestException
242-
*/
243240
public function testAmountNegativeStringThrowsException()
244241
{
242+
$this->expectException(\Omnipay\Common\Exception\InvalidRequestException::class);
243+
245244
$this->assertSame($this->request, $this->request->setAmount('-123.00'));
246245
$this->request->getAmount();
247246
}
248247

249-
/**
250-
* @expectedException \Omnipay\Common\Exception\InvalidRequestException
251-
*/
252248
public function testAmountNegativeFloatThrowsException()
253249
{
250+
$this->expectException(\Omnipay\Common\Exception\InvalidRequestException::class);
251+
254252
$this->assertSame($this->request, $this->request->setAmount(-123.00));
255253
$this->request->getAmount();
256254
}
@@ -423,12 +421,11 @@ public function testGetParameters()
423421
$this->assertEquals($expected, $this->request->getParameters());
424422
}
425423

426-
/**
427-
* @expectedException \Omnipay\Common\Exception\RuntimeException
428-
* @expectedExceptionMessage Request cannot be modified after it has been sent!
429-
*/
430424
public function testSetParameterAfterRequestSent()
431425
{
426+
$this->expectException(\Omnipay\Common\Exception\RuntimeException::class);
427+
$this->expectExceptionMessage('Request cannot be modified after it has been sent!');
428+
432429
$this->request = new AbstractRequestTest_MockAbstractRequest($this->getHttpClient(), $this->getHttpRequest());
433430
$this->request->send();
434431

@@ -450,11 +447,10 @@ public function testCanValidateAmountInteger()
450447
$this->assertNull($this->request->validate('amount'));
451448
}
452449

453-
/**
454-
* @expectedException \Omnipay\Common\Exception\InvalidRequestException
455-
*/
456450
public function testInvalidParametersThrowsException()
457451
{
452+
$this->expectException(\Omnipay\Common\Exception\InvalidRequestException::class);
453+
458454
$this->request->setTestMode(true);
459455

460456
$this->request->validate('testMode', 'token');
@@ -477,12 +473,11 @@ public function testSend()
477473
$this->assertSame($response, $this->request->send());
478474
}
479475

480-
/**
481-
* @expectedException \Omnipay\Common\Exception\RuntimeException
482-
* @expectedExceptionMessage You must call send() before accessing the Response!
483-
*/
484476
public function testGetResponseBeforeRequestSent()
485477
{
478+
$this->expectException(\Omnipay\Common\Exception\RuntimeException::class);
479+
$this->expectExceptionMessage('You must call send() before accessing the Response!');
480+
486481
$this->request = new AbstractRequestTest_MockAbstractRequest($this->getHttpClient(), $this->getHttpRequest());
487482
$this->request->getResponse();
488483
}

tests/Common/Message/AbstractResponseTest.php

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,33 +40,30 @@ public function testDefaultMethods()
4040
$this->assertEquals([], $this->response->getRedirectData());
4141
}
4242

43-
/**
44-
* @expectedException \Omnipay\Common\Exception\RuntimeException
45-
* @expectedExceptionMessage This response does not support redirection.
46-
*/
4743
public function testGetRedirectResponseNotImplemented()
4844
{
45+
$this->expectException(\Omnipay\Common\Exception\RuntimeException::class);
46+
$this->expectExceptionMessage('This response does not support redirection.');
47+
4948
$this->response->getRedirectResponse();
5049
}
5150

52-
/**
53-
* @expectedException \Omnipay\Common\Exception\RuntimeException
54-
* @expectedExceptionMessage This response does not support redirection.
55-
*/
5651
public function testGetRedirectResponseNotSupported()
5752
{
53+
$this->expectException(\Omnipay\Common\Exception\RuntimeException::class);
54+
$this->expectExceptionMessage('This response does not support redirection.');
55+
5856
$this->response = m::mock('\Omnipay\Common\Message\AbstractResponseTest_MockRedirectResponse')->makePartial();
5957
$this->response->shouldReceive('isRedirect')->once()->andReturn(false);
6058

6159
$this->response->getRedirectResponse();
6260
}
6361

64-
/**
65-
* @expectedException \Omnipay\Common\Exception\RuntimeException
66-
* @expectedExceptionMessage The given redirectUrl cannot be empty.
67-
*/
6862
public function testGetRedirectResponseUrlNotEmpty()
6963
{
64+
$this->expectException(\Omnipay\Common\Exception\RuntimeException::class);
65+
$this->expectExceptionMessage('The given redirectUrl cannot be empty.');
66+
7067
$this->response = m::mock('\Omnipay\Common\Message\AbstractResponseTest_MockRedirectResponse')->makePartial();
7168
$this->response->shouldReceive('getRedirectUrl')->once()->andReturn(null);
7269

@@ -85,7 +82,7 @@ public function testRedirect()
8582
$this->response->redirect();
8683
$body = ob_get_clean();
8784

88-
$this->assertContains('Redirecting to https://example.com/redirect?a=1&b=2', $body);
85+
$this->assertStringContainsString('Redirecting to https://example.com/redirect?a=1&b=2', $body);
8986
}
9087

9188
public function testGetRedirectResponseGet()
@@ -107,17 +104,17 @@ public function testGetRedirectResponsePost()
107104

108105
$httpResponse = $this->response->getRedirectResponse();
109106
$this->assertSame(200, $httpResponse->getStatusCode());
110-
$this->assertContains('<form action="https://example.com/redirect?a=1&amp;b=2" method="post">', $httpResponse->getContent());
111-
$this->assertContains('<input type="hidden" name="foo" value="bar" />', $httpResponse->getContent());
112-
$this->assertContains('<input type="hidden" name="key&amp;&quot;" value="&lt;value&gt;" />', $httpResponse->getContent());
107+
$this->assertStringContainsString('<form action="https://example.com/redirect?a=1&amp;b=2" method="post">', $httpResponse->getContent());
108+
$this->assertStringContainsString('<input type="hidden" name="foo" value="bar" />', $httpResponse->getContent());
109+
$this->assertStringContainsString('<input type="hidden" name="key&amp;&quot;" value="&lt;value&gt;" />', $httpResponse->getContent());
113110
}
114111

115-
/**
116-
* @expectedException \Omnipay\Common\Exception\RuntimeException
117-
* @expectedExceptionMessage Invalid redirect method "DELETE".
118-
*/
119112
public function testGetRedirectResponseInvalidMethod()
120113
{
114+
$this->expectException(\Omnipay\Common\Exception\RuntimeException::class);
115+
$this->expectExceptionMessage('Invalid redirect method "DELETE".');
116+
117+
121118
$this->response = m::mock('\Omnipay\Common\Message\AbstractResponseTest_MockRedirectResponse')->makePartial();
122119
$this->response->shouldReceive('getRedirectMethod')->andReturn('DELETE');
123120

0 commit comments

Comments
 (0)