Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 2.0.2 #76

Merged
merged 23 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1dd7900
add code coverage github action
joyet-simon Feb 1, 2024
ee960c3
use phpunit.ci.xml for code coverage tests
joyet-simon Feb 1, 2024
c71c267
Merge pull request #70 from alma/fix/rebase-develop-on-main
joyet-simon Feb 2, 2024
58d2a83
fix unit tests
joyet-simon Feb 2, 2024
3839b8a
remove double once in unit tests
joyet-simon Feb 2, 2024
3dc686b
Merge pull request #72 from alma/feature/ecom-1299-fix-unit-tests-on-…
joyet-simon Feb 2, 2024
0a80373
add code coverage github action
joyet-simon Feb 2, 2024
a26dabd
code coverage remove permission and change ubuntu version
joyet-simon Feb 5, 2024
f80e2cc
wip : Create call to Get subscriptions
Benjamin-Freoua-Alma Feb 5, 2024
96153eb
Merge pull request #73 from alma/feature/ecom-1284-add-code-coverage
joyet-simon Feb 6, 2024
feacefd
Create call to Get subscriptions
Benjamin-Freoua-Alma Feb 6, 2024
a9ddbcf
sonar: constante path request
Benjamin-Freoua-Alma Feb 6, 2024
2a17e87
add pre-commit config
joyet-simon Feb 6, 2024
618cd49
sonar: limit 120 characters authorized
Benjamin-Freoua-Alma Feb 6, 2024
206e3ab
chore: version bump
Benjamin-Freoua-Alma Feb 6, 2024
98bd3a0
Merge pull request #75 from alma/feature/ECOM-1229/create-call-to-get…
Benjamin-Freoua-Alma Feb 6, 2024
bdd2886
Merge pull request #77 from alma/feature/ecom-1296-add-pre-commit-on-…
joyet-simon Feb 8, 2024
d5a141f
[Security] Enable Vulnerability scanner on PR targeting develop
remic-alma Feb 8, 2024
19a6345
Merge pull request #78 from alma/security/enable_scan_on_pr_develop
joyet-simon Feb 8, 2024
5ad3a24
Insurance: add amount in Subscription data model
joyet-simon Feb 8, 2024
7f7f0c8
fix : use getter
Francois-Gomis Feb 8, 2024
7b859cd
add amount to api endpoint call
joyet-simon Feb 8, 2024
957d451
Merge pull request #79 from alma/fix/ECOM-1327/add_amount_to_subscrip…
joyet-simon Feb 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/code-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: PHPUnit Coverage Report

on:
push:
branches: [develop, master]
pull_request:
branches: [develop, master]
workflow_dispatch: ~

jobs:
ci:
runs-on: ubuntu-22.04
defaults:
run:
working-directory: ./

steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 5.6
tools: composer:v1

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest

- name: Ensure source code is linted
run: ./vendor/bin/phpcs src

- name: PHPUnit
run: ./vendor/bin/phpunit -c phpunit.ci.xml --coverage-xml ./.coverage
env:
XDEBUG_MODE: coverage

- name: PHPUnit threshold
run: php ./phpunit-threshold.php
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
CHANGELOG
=========

v2.0.2
-------
* Added getSubscription endpoint Insurance

v2.0.1
-------
* Fix : Don't remove amount in refund if value equal zero
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"php": "^5.6 || ~7.0 || ~7.1 || ~7.2 || ~7.3 || ~7.4 || ~8.0 || ~8.1 || ~8.2",
"psr/log": "^1 || ^2 || ^3",
"ext-curl": "*",
"ext-json": "*"
"ext-json": "*",
"ext-simplexml": "*"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
Expand Down
53 changes: 53 additions & 0 deletions phpunit-threshold.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

$file = "./.coverage/index.xml";
$coverage = simplexml_load_file($file);
$coverageIsOk = true;
$errorMessage = "";
$totals = [
[
'name' => "Lines",
'threshold' => 51,
'ratio' => (double)$coverage->project->directory->totals->lines["percent"]
],
[
'name' => "Methods",
'threshold' => 47,
'ratio' => (double)$coverage->project->directory->totals->methods["percent"]
],
[
'name' => "Functions",
'threshold' => 0,
'ratio' => (double)$coverage->project->directory->totals->functions["percent"]
],
[
'name' => "Classes",
'threshold' => 22,
'ratio' => (double)$coverage->project->directory->totals->classes["percent"]
],
[
'name' => "Traits",
'threshold' => 0,
'ratio' => (double)$coverage->project->directory->totals->traits["percent"]
]
];

foreach ($totals as $total) {
if ($total['ratio'] < $total['threshold']) {
echo "{$total['name']} coverage failed! \r\n";
echo "{$total['name']} coverage: {$total['ratio']}% \r\n";
echo "Threshold: {$total['threshold']}% \r\n";
$coverageIsOk = false;
$errorMessage .= "{$total['name']} coverage failed! \r\n";
} else {
echo "{$total['name']} coverage success: {$total['ratio']}% \r\n";
}
}

if (!$coverageIsOk) {
echo "Coverage failed! \r\n";
echo $errorMessage;
exit(1);
} else {
echo "Coverage success! \r\n";
}
9 changes: 8 additions & 1 deletion phpunit.ci.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,12 @@
<directory>tests/Unit/Legacy</directory>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src/*</directory>
<exclude>
<directory suffix=".php">./src/vendor/*</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
2 changes: 1 addition & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

class Client
{
const VERSION = '2.0.1';
const VERSION = '2.0.2';

const LIVE_MODE = 'live';
const TEST_MODE = 'test';
Expand Down
23 changes: 22 additions & 1 deletion src/Endpoints/Insurance.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Insurance extends Base
/**
* @var InsuranceValidator
*/
protected $insuranceValidator;
public $insuranceValidator;

public function __construct($client_context)
{
Expand Down Expand Up @@ -130,7 +130,28 @@ public function subscription($subscriptionArray, $paymentId = null, $customerSes
$response = $request->post();

if ($response->isError()) {
throw new RequestException($response->errorMessage, null, $response);
}

return $response->json;
}

/**
* @throws RequestError
* @throws RequestException
* @throws ParametersException
* @return array json_decode in response constructor
*/
public function getSubscription($subscriptionIds)
{
$this->insuranceValidator->checkSubscriptionIds($subscriptionIds);
$response = $this->request(
self::INSURANCE_PATH . 'subscriptions'
)->setQueryParams(
$subscriptionIds
)->get();

if ($response->isError()) {
throw new RequestException($response->errorMessage, null, $response);
}

Expand Down
13 changes: 13 additions & 0 deletions src/Lib/InsuranceValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,17 @@ public function checkParamFormat($param, $name)
));
}
}

/**
* @throws ParametersException
*/
public function checkSubscriptionIds($subscriptionIds)
{
if (!is_array($subscriptionIds)) {
throw new ParametersException(sprintf(
'The subscription ids need to be an array, "%s" given',
gettype($subscriptionIds)
));
}
}
}
Loading