Skip to content

Commit

Permalink
tests: add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
bernard-ng committed Oct 13, 2023
1 parent 2543e95 commit 5b12559
Show file tree
Hide file tree
Showing 11 changed files with 2,027 additions and 38 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Lint
on: [push]
jobs:
lint:
name: PHP Lint
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2

- name: Cache Composer dependencies
uses: actions/cache@v2
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}

- uses: actions/checkout@master
- name: test
run: make test
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
/vendor/
.idea
.phpunit.result.cache
.phpunit.cache
.vscode
index.php
34 changes: 29 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,40 @@
.DEFAULT_GOAL := help

# -----------------------------------
# Variables
# -----------------------------------
is_docker := $(shell docker info > /dev/null 2>&1 && echo 1)
user := $(shell id -u)
group := $(shell id -g)

ifeq ($(is_docker), 1)
php := USER_ID=$(user) GROUP_ID=$(group) docker-compose run --rm --no-deps php
composer := $(php) composer
else
php := php
composer := composer
endif

# -----------------------------------
# Recipes
# -----------------------------------
.PHONY: help
help: ## affiche cet aide
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: lint
lint: vendor/autoload.php ## affiche les erreurs de formatage de code
php vendor/bin/ecs
php vendor/bin/phpstan
$(php) vendor/bin/ecs
$(php) vendor/bin/phpstan

.PHONY: test
test: vendor/autoload.php ## lance les tests
$(php) vendor/bin/phpunit

.PHONY: lint-fix
lint-fix: vendor/autoload.php ## corrige les erreurs de formatage de code
php vendor/bin/ecs --fix
$(php) vendor/bin/ecs --fix

vendor/autoload.php: composer.lock # installe les dépendances PHP
composer update
composer dump-autoload
$(composer) update
$(composer) dump-autoload
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Maxicash PHP

![Lint](https://github.com/devscast/maxicash/actions/workflows/lint.yaml/badge.svg)
![Test](https://github.com/devscast/maxicash/actions/workflows/test.yaml/badge.svg)
[![Latest Stable Version](https://poser.pugx.org/devscast/maxicash/version)](https://packagist.org/packages/devscast/maxicash)
[![Total Downloads](https://poser.pugx.org/devscast/maxicash/downloads)](https://packagist.org/packages/devscast/maxicash)
[![License](https://poser.pugx.org/devscast/maxicash/license)](https://packagist.org/packages/devscast/maxicash)
Expand All @@ -20,7 +21,7 @@ The MaxiCash Gateway enables the Merchant to Collect Payment into their MaxiCash
### Authentication
* **Step 1**. Download the MaxiCash Mobile App and signup...
* **Step 2**. Contact us to upgrade your account to a Merchant Account info@maxicashapp.com
You will receive a Merchant Form to complete in order to provide your business details and preffered Cashout Wallet or Banking Details.
You will receive a Merchant Form to complete in order to provide your business details and preferred Cash out Wallet or Banking Details.
* **Step 3**. Once the paperwork is completed, you will be issued with Live and Sandbox Accounts (MerchantID and MerchantPassword)


Expand Down Expand Up @@ -58,7 +59,7 @@ $url = $maxicash->queryStringURLPayment($entry);
> **Note** : we highly recommand to do a `server side` redirection, this url can be modified and leak your maxicash credentials when displayed to your user in any manner (eg: a link, button or form) ! you can use the `header("Location: $url")` fonction in vanilla PHP or return a `RedirectResponse($url)` in your controller when using Symfony or Laravel frameworks`
### Donate Button for NGOs
Once you signup as an NGO Merchant
Once you sign up as an NGO Merchant

```php
$donationUrl = $maxicash->donationUrl()
Expand Down
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
"Devscast\\Maxicash\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Devscast\\Maxicash\\Tests\\": "tests/"
}
},
"authors": [
{
"name": "bernard-ng",
Expand All @@ -23,7 +28,8 @@
"minimum-stability": "stable",
"require-dev": {
"phpstan/phpstan": "^1.10",
"symplify/easy-coding-standard": "^12.0"
"symplify/easy-coding-standard": "^12.0",
"phpunit/phpunit": "^10.4"
},
"require": {
"php": ">=8.2",
Expand Down
Loading

0 comments on commit 5b12559

Please sign in to comment.