Skip to content

Commit 3f28481

Browse files
authored
Merge pull request #3 from superbrave/scrutinizer
Adds Scrutinizer to this project.
2 parents 708acd1 + 09a821b commit 3f28481

File tree

7 files changed

+148
-4
lines changed

7 files changed

+148
-4
lines changed

.scrutinizer.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
filter:
2+
paths:
3+
- src/
4+
5+
excluded_paths:
6+
- bin/
7+
- tests
8+
- var/
9+
10+
dependency_paths:
11+
- vendor/
12+
13+
checks:
14+
php: true
15+
16+
build:
17+
dependencies:
18+
override:
19+
- composer install --no-interaction --prefer-dist --optimize-autoloader
20+
21+
nodes:
22+
composer-file-validation:
23+
dependencies:
24+
override:
25+
- true
26+
27+
tests:
28+
override:
29+
- composer validate
30+
31+
code-standards:
32+
tests:
33+
override:
34+
- ./bin/php-cs-fixer fix --dry-run -v
35+
36+
security-check:
37+
requires:
38+
- branch: master
39+
40+
dependencies:
41+
override:
42+
- true
43+
44+
tests:
45+
override:
46+
- if [ -z "$SCRUTINIZER_PR_SOURCE_BRANCH" ]; then curl -o security-checker.phar https://get.sensiolabs.org/security-checker.phar; fi;
47+
- if [ -z "$SCRUTINIZER_PR_SOURCE_BRANCH" ]; then php security-checker.phar security:check; fi;
48+
49+
phpunit:
50+
requires:
51+
- node: composer-file-validation
52+
- node: code-standards
53+
54+
tests:
55+
override:
56+
- command: ./bin/phpunit --coverage-clover=code-coverage
57+
coverage:
58+
file: code-coverage
59+
format: clover
60+
61+
static-code-analysis:
62+
tests:
63+
override:
64+
- php-scrutinizer-run
65+
66+
environment:
67+
php:
68+
version: 7.2
69+
pecl_extensions:
70+
- zip
71+
72+
build_failure_conditions:
73+
- 'elements.rating(<= D).new.exists' # No new classes/methods with a rating of D or worse.
74+
- 'project.metric("scrutinizer.quality", < 8)' # Code Quality Rating drops below 8.
75+
- 'project.metric("scrutinizer.test_coverage", < 0.80)' # Code Coverage drops below 80%.

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Omnipay: Icepay Payments (ICEX2.0)
2+
[![Build Status](https://scrutinizer-ci.com/g/superbrave/omnipay-icepay-payments/badges/build.png?b=master)](https://scrutinizer-ci.com/g/superbrave/omnipay-icepay-payments/build-status/master)
3+
[![Code Coverage](https://scrutinizer-ci.com/g/superbrave/omnipay-icepay-payments/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/superbrave/omnipay-icepay-payments/?branch=master)
4+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/superbrave/omnipay-icepay-payments/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/superbrave/omnipay-icepay-payments/?branch=master)
25
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
36

47
## Introduction
@@ -88,7 +91,6 @@ $request = $gateway->authorize($data);
8891

8992
$response = $response->send();
9093
```
91-
This will return the order details as well as the checkout HTML snippet to render on your site.
9294

9395
[API documentation](http://docs2.icepay.com/calling-our-webservice/transaction-functions/)
9496

@@ -108,7 +110,7 @@ $response = $request->send();
108110
[API documentation](https://icepay2.docs.apiary.io/#reference/0/transaction)
109111

110112
### Refund
111-
*Do note: refunds have not been tested in production*
113+
*Do note: refunds implementation has not been tested.*
112114

113115
```php
114116
$request = $gateway->refund([

src/Message/RefundRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function getData(): array
3030
/**
3131
* {@inheritdoc}
3232
*
33-
* @throws InvalidRequestException When transaction reference is not set.
33+
* @throws InvalidRequestException when transaction reference is not set
3434
*/
3535
public function sendData($data): ResponseInterface
3636
{
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
namespace Omnipay\IcepayPayments\Message;
4+
5+
use Omnipay\IcepayPayments\AbstractTestCase;
6+
7+
/**
8+
* Class RefundResponseTest.
9+
*/
10+
class RefundResponseTest extends AbstractTestCase
11+
{
12+
/**
13+
* @var TransactionStatusRequest
14+
*/
15+
private $request;
16+
17+
/**
18+
* Creates a new TransactionStatusRequest instance.
19+
*/
20+
protected function setUp(): void
21+
{
22+
parent::setUp();
23+
24+
$this->request = new RefundRequest($this->httpClient, $this->httpRequest);
25+
}
26+
27+
/**
28+
* Tests if TransactionStatusResponse::isSuccessful will return true with the given json response.
29+
*/
30+
public function testResponseReturnsSuccessful(): void
31+
{
32+
$responseJsonBody = file_get_contents(__DIR__.'/../Mocks/RefundSuccess.json');
33+
$response = new RefundResponse($this->request, json_decode($responseJsonBody, true));
34+
35+
$expectedResponseBody = [
36+
'RefundId' => '7c9cb2f4-83ce-4b10-8d5c-de230181224f',
37+
'RefundStatusCode' => AbstractResponse::RESPONSE_STATUS_COMPLETED,
38+
'RefundStatusDetails' => '',
39+
'AcquirerRefundId' => '',
40+
];
41+
42+
$this->assertTrue($response->isSuccessful());
43+
$this->assertSame($expectedResponseBody, $response->getData());
44+
}
45+
46+
/**
47+
* Tests if TransactionStatusResponse::isSuccessful will return false from the json response.
48+
*/
49+
public function testIfResponseReturnNotSuccessful(): void
50+
{
51+
$responseJsonBody = file_get_contents(__DIR__.'/../Mocks/RefundFail.json');
52+
$response = new RefundResponse($this->request, json_decode($responseJsonBody, true));
53+
54+
$this->assertFalse($response->isSuccessful());
55+
}
56+
}

tests/Message/TransactionStatusResponseTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ protected function setUp(): void
2222
parent::setUp();
2323

2424
$this->request = new TransactionStatusRequest($this->httpClient, $this->httpRequest);
25+
$this->request->setTransactionReference('7c9cb2f4-83ce-4b10-8d5c-de230181224f');
2526
}
2627

2728
/**
@@ -42,6 +43,7 @@ public function testResponseReturnsSuccessful(): void
4243

4344
$this->assertTrue($response->isSuccessful());
4445
$this->assertSame($expectedResponseBody, $response->getData());
46+
$this->assertSame($expectedResponseBody['transactionId'], $response->getTransactionReference());
4547
}
4648

4749
/**
@@ -50,7 +52,7 @@ public function testResponseReturnsSuccessful(): void
5052
public function testIfResponseReturnNotSuccessful(): void
5153
{
5254
$responseJsonBody = file_get_contents(__DIR__.'/../Mocks/TransactionStatusFail.json');
53-
$response = new CreateTransactionResponse($this->request, json_decode($responseJsonBody, true));
55+
$response = new TransactionStatusResponse($this->request, json_decode($responseJsonBody, true));
5456

5557
$this->assertFalse($response->isSuccessful());
5658
}

tests/Mocks/RefundFail.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"RefundStatusCode": ""
3+
}

tests/Mocks/RefundSuccess.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"RefundId": "7c9cb2f4-83ce-4b10-8d5c-de230181224f",
3+
"RefundStatusCode": "COMPLETED",
4+
"RefundStatusDetails": "",
5+
"AcquirerRefundId": ""
6+
}

0 commit comments

Comments
 (0)