Skip to content

Commit

Permalink
USSD V3 Beta (#40)
Browse files Browse the repository at this point in the history
* Laravel 10 dependencies (#32) (#38)

Co-authored-by: Samuel Mwangi <samuel@samuelmwangi.co.ke>

* USSD V3 (#39)

* Version 3.0 wip

* Try github actions for testing

* Update build badges

* Listing pagination aid

* Limit content aid

* Making limit content, paginate and terminate play nice together

* Format code with php cs fixer

* Trim output and add conditional trait

* Validate continuing mode

* Refector to use method for exception-handler and response

* Import InvalidArgumentException in Testing

* Specify PHP version

* Use decision instead of string for continuing state

* Allow creating state or action as initial state with option

* Formatting menu helper and caching current page

* Rename LimitContent to Truncate and add testing util for time waiting

* Timeout resumation is based on last session and not begining of session

* Add exception handler command and refactor command tests

* Make Ussd useContext chainable and put exception handlers in the ussd directory

* Typehint functions

* Use docblock for ServiceProvider

* Better exceptions

* Improve readme

* Move some of Ussd functionality to UssdBuilder

---------

Co-authored-by: Samuel Mwangi <samuel@samuelmwangi.co.ke>
  • Loading branch information
cybersai and SamuelMwangiW committed Jan 21, 2024
1 parent d520b24 commit 5d8d431
Show file tree
Hide file tree
Showing 125 changed files with 3,973 additions and 2,120 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Tests

on:
push:
branches: [ "3.x" ]
pull_request:
branches: [ "3.x" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

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

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run test suite
run: composer run-script test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/vendor
composer.lock
.phpunit.result.cache
.php-cs-fixer.cache
testbench/
/coverage
.DS_Store
13 changes: 13 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

return (new PhpCsFixer\Config())
->setRules([
'@PSR12' => true,
'@PHP80Migration' => true,
'yoda_style' => true,
'no_unused_imports' => true,
'ordered_imports' => true,
'ordered_class_elements' => true,
'ordered_types' => true,
])
->setFinder((new PhpCsFixer\Finder())->in(__DIR__ . '/src'));
27 changes: 24 additions & 3 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@ All notable changes to `laravel Ussd` will be documented in this file.

## [Unreleased]

## [v3.0.0-beta.1] - 2024-01-21
### Removed
- Removed machine in favor of USSD facade.

### Changed
- Changed state interface.
- Changed record implementation and public apis.
- Changed config variables

### Added
- Added `Transition`, `Paginate`, `Truncate` and `Terminate` Attributes.
- Added Custom Exception Handling.
- Added command to create responses, exception handlers and decisions.
- Added decision classes for navigating USSD menus.
- Added testing utility to Ussd Facade.
- Added pagination utility.
- Added resumability of timed-out sessions.
- Added interfaces for decision, exception handler, response, initial state and initial action.
- Added support for dependency injection.
- Added USSD context.

## [v2.5.0] - 2022-06-19
### Added
- Add configuring USSDs using decorator pattern.
Expand All @@ -17,13 +38,11 @@ All notable changes to `laravel Ussd` will be documented in this file.
- Clean up

## [v2.4.0] - 2022-02-22

### Added
- Add Laravel 9 support
- Add PHP 8.1 support

## [v2.3.1] - 2021-10-15

### Fixed
- Coding style

Expand All @@ -50,6 +69,7 @@ All notable changes to `laravel Ussd` will be documented in this file.
- Artisan command to create action class
- increment method to records
- decrement method to records

### Changed
- config file class namespace split to action and state namespace
- Updated changelog
Expand Down Expand Up @@ -82,7 +102,8 @@ All notable changes to `laravel Ussd` will be documented in this file.
- Ussd config to allow developers customize behaviour
- Ussd service Provider class to allow laravel know how to integrate the package

[Unreleased]: ../../compare/v2.5.0...HEAD
[Unreleased]: ../../compare/v3.0.0-beta.1...HEAD
[v3.0.0-beta.1]: ../../compare/v2.5.0...v3.0.0-beta.1
[v2.5.0]: ../../compare/v2.4.2...v2.5.0
[v2.4.2]: ../../compare/v2.4.1...v2.4.2
[v2.4.1]: ../../compare/v2.4.0...v2.4.1
Expand Down
26 changes: 16 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,26 @@
"license": "MIT",
"authors": [
{
"name": "Sparors Inc",
"name": "Isaac Sai",
"email": "isaacsai030@gmail.com",
"homepage": "https://sparors.github.io"
},
{
"name": "Benjamin Manford",
"email": "benjaminmanford@gmail.com",
"homepage": "https://sparors.github.io"
}
],
"homepage": "https://github.com/sparors/laravel-ussd",
"keywords": ["Laravel", "Ussd"],
"require": {
"illuminate/support": "~5|~6|~7|~8|~9|~10"
"php": "^8.0",
"illuminate/support": "~8|~9|~10"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"mockery/mockery": "^1.1",
"orchestra/testbench": "~3|~4|~5|~6|~7|~8",
"sempro/phpunit-pretty-print": "^1.0"
"phpunit/phpunit": "^9.6",
"orchestra/testbench": "~6|~7|~8",
"friendsofphp/php-cs-fixer": "^3.41"
},
"autoload": {
"psr-4": {
Expand All @@ -34,10 +39,11 @@
"laravel": {
"providers": [
"Sparors\\Ussd\\UssdServiceProvider"
],
"aliases": {
"Ussd": "Sparors\\Ussd\\Facades\\Ussd"
}
]
}
},
"scripts": {
"test": "vendor/bin/phpunit",
"format": "vendor/bin/php-cs-fixer fix"
}
}
49 changes: 6 additions & 43 deletions config/ussd.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,62 +4,25 @@

/*
|--------------------------------------------------------------------------
| State Class Namespace
| USSD Namespace
|--------------------------------------------------------------------------
|
| This value sets the root namespace for Ussd State component classes in
| your application.
| This sets the root namespace for USSD component classes.
|
*/

'state_namespace' => env('USSD_STATE_NS', 'App\\Http\\Ussd\\States'),
'namespace' => env('USSD_NAMESPACE', 'App\Ussd'),

/*
|--------------------------------------------------------------------------
| Action Class Namespace
|--------------------------------------------------------------------------
|
| This value sets the root namespace for Ussd Action component classes in
| your application.
|
*/

'action_namespace' => env('USSD_ACTION_NS', 'App\\Http\\Ussd\\Actions'),

/*
|--------------------------------------------------------------------------
| Store
| Record Store
|--------------------------------------------------------------------------
|
| This value sets the default store to use for the ussd record.
| The store can be found in your cache stores config
| This sets the cache store to be used by USSD Record.
|
*/

'cache_store' => env('USSD_STORE', null),


/*
|--------------------------------------------------------------------------
| Time to live
|--------------------------------------------------------------------------
|
| This value sets the default for how long the record values are to
| be cached in your application when not specified.
|
*/

'cache_ttl' => env('USSD_TTL', null),

/*
|--------------------------------------------------------------------------
| Default value
|--------------------------------------------------------------------------
|
| This value return the default store value when a given cache key
| is not found
|
*/
'record_store' => env('USSD_STORE'),

'cache_default' => env('USSD_DEFAULT_VALUE', null),
];
1 change: 0 additions & 1 deletion contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Contributions are accepted via Pull Requests on [Github](https://github.com/spar

# Things you could do
If you want to contribute but do not know where to start, this list provides some starting points.
- Set up TravisCI
- Write a comprehensive ReadMe

## Pull Requests
Expand Down
16 changes: 7 additions & 9 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,22 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
testdox="true"
processIsolation="false"
stopOnFailure="false"
printerClass="Sempro\PHPUnitPrettyPrinter\PrettyPrinterForPhpUnit9"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd">
<coverage>
<include>
<directory>src/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Package">
<directory suffix=".php">./tests/</directory>
<testsuite name="Unit">
<directory suffix=".php">./tests/Unit/</directory>
</testsuite>
<testsuite name="Integration">
<directory suffix=".php">./tests/Integration/</directory>
</testsuite>
</testsuites>
</phpunit>
Loading

0 comments on commit 5d8d431

Please sign in to comment.