Skip to content

Commit

Permalink
Release v2.3 (#14)
Browse files Browse the repository at this point in the history
* Upgrade Tests (#13)

* Upgrade Tests

* Remove Php 7.2 in build

* Update .travis.yml

* Use Php 7.4

* Remove Codecov because of unneccesary errors

* remove test coverage

* Update Changelog links

* Update Changelog
  • Loading branch information
cybersai committed Jun 27, 2021
1 parent e337784 commit a2eed85
Show file tree
Hide file tree
Showing 23 changed files with 259 additions and 206 deletions.
36 changes: 0 additions & 36 deletions .github/workflows/php.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
/vendor
composer.lock
.phpunit.result.cache
testbench/
testbench/
/coverage
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
language: php

php:
- '7.2'
- '7.3'
- '7.4'
- '8.0'

sudo: false

Expand All @@ -16,4 +16,4 @@ before_script:
- travis_retry composer update --no-interaction --prefer-dist

script:
- vendor/bin/phpunit
- vendor/bin/phpunit
14 changes: 12 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@ All notable changes to `laravel Ussd` will be documented in this file.

## [Unreleased]

## [v2.3.0] - 2021-06-27
### Added
- Add missen test to improve coverage
### Change
- Minor bug fixes
- Upgrade test dependencies


## [v2.2.0] - 2020-09-11
### Added
- Add Support for laravel 8

## [v2.1.0] - 2020-05-26
Expand Down Expand Up @@ -35,7 +44,7 @@ All notable changes to `laravel Ussd` will be documented in this file.
- Updated Readme
- Updated changelog

## [v0.1.0] - 2020-05-02
## [v0.1.0] - 2020-05-02
### Added
- Ussd Package Project with README, contributing, changelog, license, etc.
- State class to define what should occur at various stages when user navigates
Expand All @@ -50,7 +59,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.2.0...HEAD
[Unreleased]: ../../compare/v2.3.0...HEAD
[v2.3.0]: ../../compare/v2.2.0...v2.3.0
[v2.2.0]: ../../compare/v2.1.0...v2.2.0
[v2.1.0]: ../../compare/v2.0.0...v2.1.0
[v2.0.0]: ../../compare/v1.0.0...v2.0.0
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"illuminate/support": "~5|~6|~7|~8"
},
"require-dev": {
"phpunit/phpunit": "^8.0",
"phpunit/phpunit": "^9.5",
"mockery/mockery": "^1.1",
"orchestra/testbench": "~3|~4|~5",
"orchestra/testbench": "~3|~4|~5|~6",
"sempro/phpunit-pretty-print": "^1.0"
},
"autoload": {
Expand Down
43 changes: 23 additions & 20 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Package">
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>src/</directory>
</whitelist>
</filter>
<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"
processIsolation="false"
stopOnFailure="false"
printerClass="Sempro\PHPUnitPrettyPrinter\PrettyPrinterForPhpUnit9"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory>src/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Package">
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ class MakePayment extends Action
$response = Http::post('/payment', [
'phone_number' => $this->record->phoneNumber
]);

if ($response->ok()) {
return PaymentSuccess::class;
}

return PaymentError::class;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Decision.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Decision

/** @var mixed */
protected $argument;

/** @var string|null */
protected $output;

Expand Down Expand Up @@ -127,18 +127,18 @@ public function in(array $array, string $output, bool $strict = false): self
{
return $this->setOutputForCondition(
function () use ($array, $strict) {
return in_array($array, $this->argument, $strict);
return in_array($this->argument, $array, $strict);
},
$output
);
}

public function custom(callable $function, string $output): self
{
$func = function () use ($function) {
$func = function () use ($function) {
return $function($this->argument);
};

return $this->setOutputForCondition($func, $output);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class Menu
{
const NUMBERING_ALPHABETIC_LOWER = 'alphabetic_lower';
const NUMBERING_ALPHABETIC_UPPER = 'alphabetic_lower';
const NUMBERING_ALPHABETIC_UPPER = 'alphabetic_upper';
const NUMBERING_EMPTY = 'empty';
const NUMBERING_NUMERIC = 'numeric';

Expand Down
21 changes: 15 additions & 6 deletions src/Record.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ protected function getTtl($ttl)
return $ttl ?? config('ussd.cache_ttl');
}

/**
* @param string $default
* @return mixed
*/
protected function getDefault($default)
{
return $default ?? config('ussd.cache_default');
}

/**
* @param array $keys
* @return array
Expand Down Expand Up @@ -83,7 +92,7 @@ public function has($key)
*/
public function set($key, $value, $ttl = null)
{
return $this->cache->set($this->getKey($key), $value, $ttl);
return $this->cache->set($this->getKey($key), $value, $this->getTtl($ttl));
}

/**
Expand All @@ -95,7 +104,7 @@ public function set($key, $value, $ttl = null)
*/
public function setMultiple($values, $ttl = null)
{
return $this->cache->setMultiple($this->getValues($values), $ttl);
return $this->cache->setMultiple($this->getValues($values), $this->getTtl($ttl));
}

/**
Expand All @@ -107,7 +116,7 @@ public function setMultiple($values, $ttl = null)
*/
public function get($key, $default = null)
{
return $this->cache->get($this->getKey($key), $default);
return $this->cache->get($this->getKey($key), $this->getDefault($default));
}

/**
Expand All @@ -122,7 +131,7 @@ public function get($key, $default = null)
public function getMultiple($keys, $default = null)
{
return array_values(
(array)$this->cache->getMultiple($this->getKeys($keys), $default)
(array)$this->cache->getMultiple($this->getKeys($keys), $this->getDefault($default))
);
}

Expand Down Expand Up @@ -150,7 +159,7 @@ public function deleteMultiple($keys)

/**
* Increment the value of an item in the cache.
*
*
* @since v2.0.0
* @param string $key
* @param mixed $value
Expand Down Expand Up @@ -209,7 +218,7 @@ public function __invoke($argument)
if (is_string($argument)) {
return $this->get($argument, config('ussd.cache_default'));
}

if (is_array($argument)) {
$this->setMultiple($argument, config('ussd.cache_ttl'));
}
Expand Down
21 changes: 1 addition & 20 deletions src/Ussd.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Ussd
{
/**
* An instance on Application
*
*
* @var \Illuminate\Contracts\Foundation\Application
*/
protected $app;
Expand All @@ -18,25 +18,6 @@ public function __construct($app)
$this->app = $app;
}

/**
* @param string $id;
* @param string $store
* @return Record
*/
public function record(string $id, string $store = null)
{
return new Record(Cache::store($store), $id);
}

/**
* @param string $menu
* @return Menu
*/
public function menu(string $menu = '')
{
return new Menu($menu);
}

/**
* @return Machine
*/
Expand Down
7 changes: 3 additions & 4 deletions tests/ActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

namespace Sparors\Ussd\Tests;

use Orchestra\Testbench\TestCase;
use Sparors\Ussd\State;
use PHPUnit\Framework\TestCase;


/** @internal */
class ActionTest extends TestCase
{
public function testAction()
public function test_it_runs_successfully()
{
$action = new RunAction();
$this->assertEquals(ByeState::class, $action->run());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,12 @@

namespace Sparors\Ussd\Tests\Commands;

use Sparors\Ussd\Tests\TestCase;
use Illuminate\Support\Facades\File;
use Orchestra\Testbench\TestCase;
use Sparors\Ussd\UssdServiceProvider;

class TestActionCommand extends TestCase
class ActionCommandTest extends TestCase
{
/**
* Tell Testbench to use this package.
*
* @param $app
*
* @return array
*/
public function getPackageProviders($app)
{
return [UssdServiceProvider::class];
}

public function testItPrintOutSuccessWhenClassDoesNotExists()
public function test_it_print_out_success_when_class_does_not_exists()
{
File::shouldReceive('exists')->once()->andReturn(false);
File::shouldReceive('isDirectory')->once();
Expand All @@ -31,10 +18,10 @@ public function testItPrintOutSuccessWhenClassDoesNotExists()
->assertExitCode(0);
}

public function testItPrintOutErrorWhenClassExists()
public function test_it_print_out_error_when_class_exists()
{
File::shouldReceive('exists')->once()->andReturn(true);
$this->artisan('ussd:state', ['name' => 'save'])
$this->artisan('ussd:action', ['name' => 'save'])
->expectsOutput('File Already exists !')
->assertExitCode(0);
}
Expand Down
Loading

0 comments on commit a2eed85

Please sign in to comment.