diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 2ca55d3..639169c 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -5,10 +5,7 @@ build: environment: php: - version: 7.2 - pecl_extensions: - - memcached - memcached: true + version: 7.3 nodes: analysis: @@ -17,9 +14,8 @@ build: tests: override: - php-scrutinizer-run - - command: vendor/bin/phpunit --dump-xdebug-filter xdebug-filter.php - - command: vendor/bin/phpunit --prepend xdebug-filter.php --coverage-clover=clover.xml + command: vendor/bin/phpunit --coverage-clover=clover.xml coverage: file: clover.xml format: php-clover diff --git a/.travis.yml b/.travis.yml index 7db0943..fe1e060 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,9 @@ language: php php: - - '7.2' - '7.3' - '7.4' - 'nightly' -services: - - memcached - matrix: allow_failures: - php: 'nightly' @@ -15,7 +11,6 @@ matrix: before_script: - pecl install pcov - phpenv config-rm xdebug.ini || echo "xdebug not available" - - bash <(curl -s https://raw.githubusercontent.com/php-cache/cache/master/build/php/7.2/Memcached.sh) - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter - chmod +x ./cc-test-reporter - if [ $(phpenv version-name) = "7.4" ]; then ./cc-test-reporter before-build; fi diff --git a/README.md b/README.md index 0c09d97..b6dd7cd 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ laravel-wallet-swap - Addition to the package laravel-wallet. * **Package**: laravel-wallet-swap * **Version**: [![Latest Stable Version](https://poser.pugx.org/bavix/laravel-wallet-swap/v/stable)](https://packagist.org/packages/bavix/laravel-wallet-swap) * **PHP Version**: 7.1+ -* **Laravel Version**: `5.5`, `5.6`, `5.7`, `5.8`, `6.x`, `7.x` +* **Laravel Version**: `5.5`, `5.6`, `5.7`, `5.8`, `6.x`, `7.x`, `8.x` * **[Composer](https://getcomposer.org/):** `composer require bavix/laravel-wallet-swap` --- diff --git a/changelog.md b/changelog.md index c470cc2..2aade23 100644 --- a/changelog.md +++ b/changelog.md @@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [3.0.0] - 2020-11-13 + +### Added +- support laravel-wallet v6.0 +- support php ^8.0 +- More unit tests + ## [2.0.0] - 2020-03-13 ### Added @@ -36,7 +43,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add class provider `RateServiceProvider`. - Add class rate for laravel-wallet `Rate`. -[Unreleased]: https://github.com/bavix/laravel-wallet-swap/compare/2.0.0...develop +[Unreleased]: https://github.com/bavix/laravel-wallet-swap/compare/3.0.0...develop +[3.0.0]: https://github.com/bavix/laravel-wallet-swap/compare/2.0.0...3.0.0 [2.0.0]: https://github.com/bavix/laravel-wallet-swap/compare/1.1.0...2.0.0 [1.1.0]: https://github.com/bavix/laravel-wallet-swap/compare/1.0.0...1.1.0 [1.0.0]: https://github.com/bavix/laravel-wallet-swap/compare/0.0.2...1.0.0 diff --git a/composer.json b/composer.json index 1eb3bb8..9aa3ff8 100644 --- a/composer.json +++ b/composer.json @@ -6,11 +6,13 @@ "laravel", "laravel6", "laravel7", + "laravel8", "credits", "bavix", "currency", "laravel6-package", "laravel7-package", + "laravel8-package", "laravel-wallet", "virtual", "wallet", @@ -26,18 +28,18 @@ } ], "require": { - "php": "^7.2", - "bavix/laravel-wallet": "^5.0", - "florianv/laravel-swap": "^2.1", - "nyholm/psr7": "^1.2", + "php": "^7.3|^8.0", + "bavix/laravel-wallet": "^6.0", + "florianv/laravel-swap": "^2.2", + "nyholm/psr7": "^1.3", "php-http/curl-client": "^2.1", - "php-http/message": "^1.8" + "php-http/message": "^1.9" }, "require-dev": { - "infection/infection": "^0.15", - "orchestra/testbench": "^4.0|^5.0", + "infection/infection": "~0.17", + "orchestra/testbench": "^6.0", "phpstan/phpstan": "^0.12", - "phpunit/phpunit": "^8.0|^9.0" + "phpunit/phpunit": "^9.4" }, "autoload": { "psr-4": { @@ -50,9 +52,6 @@ } }, "extra": { - "branch-alias": { - "dev-develop": "2.0.x-dev" - }, "laravel": { "providers": [ "Bavix\\WalletSwap\\RateServiceProvider" diff --git a/phpunit.xml b/phpunit.xml index 33764d0..70b0ec2 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -23,4 +23,7 @@ + + + diff --git a/src/Rate.php b/src/Rate.php index 9b5a404..4f08278 100644 --- a/src/Rate.php +++ b/src/Rate.php @@ -12,7 +12,6 @@ class Rate extends Rateable { - /** * The method calculates the rate between currencies. * Makes a request for an API Swap and receives data. @@ -38,6 +37,7 @@ public function rate(Wallet $wallet) * @var ExchangeRate $rate */ $rate = Swap::latest($pair); + return $rate->getValue(); } @@ -52,5 +52,4 @@ public function convertTo(Wallet $wallet) $this->rate($wallet) ); } - } diff --git a/src/RateServiceProvider.php b/src/RateServiceProvider.php index 0e29ada..a8eaaf5 100644 --- a/src/RateServiceProvider.php +++ b/src/RateServiceProvider.php @@ -2,12 +2,11 @@ namespace Bavix\WalletSwap; -use Illuminate\Support\ServiceProvider; use Bavix\Wallet\Interfaces\Rateable; +use Illuminate\Support\ServiceProvider; class RateServiceProvider extends ServiceProvider { - /** * Bootstrap services. * @@ -16,11 +15,10 @@ class RateServiceProvider extends ServiceProvider */ public function boot(): void { - if (!$this->app->runningInConsole()) { + if (! $this->app->runningInConsole()) { return; } $this->app->singleton(Rateable::class, Rate::class); } - } diff --git a/tests/RateTest.php b/tests/RateTest.php index 2e7d197..bbe3a19 100644 --- a/tests/RateTest.php +++ b/tests/RateTest.php @@ -2,6 +2,7 @@ namespace Bavix\WalletSwap\Test; +use Bavix\Wallet\Interfaces\Mathable; use Bavix\Wallet\Models\Wallet; use Bavix\WalletSwap\Rate; use Exchanger\ExchangeRate; @@ -9,7 +10,6 @@ class RateTest extends TestCase { - /** * @return void */ @@ -36,7 +36,7 @@ public function testSimple(): void */ $expected = Swap::latest('USD/EUR'); - $this->assertEquals($expected->getValue() * 99, $rate->convertTo($eur)); + self::assertEquals($expected->getValue() * 99, $rate->convertTo($eur)); } /** @@ -54,7 +54,7 @@ public function testIdentical(): void ->withCurrency($usd) ->withAmount(128); - $this->assertEquals(128, $rate->convertTo($usd)); + self::assertEquals(128, $rate->convertTo($usd)); } /** @@ -83,7 +83,7 @@ public function testCryptoBTCUSD(): void */ $expected = Swap::latest('BTC/USD'); - $this->assertEquals($expected->getValue() * 20, $rate->convertTo($usd)); + self::assertEquals($expected->getValue() * 20, $rate->convertTo($usd)); } /** @@ -111,15 +111,15 @@ public function testCryptoUSDBTC(): void * @var ExchangeRate $expected */ $expected = Swap::latest('USD/BTC'); - $this->assertEquals($expected->getValue() * 100, $rate->convertTo($btc)); - $this->assertEquals($expected->getValue(), $rate->rate($btc)); + self::assertEquals($expected->getValue() * 100, $rate->convertTo($btc)); + self::assertEquals($expected->getValue(), $rate->rate($btc)); /** * @var ExchangeRate $expected */ $expected = Swap::latest('BTC/USD'); - $this->assertEquals($expected->getValue() * 100, $rate->withCurrency($btc)->convertTo($usd)); - $this->assertEquals($expected->getValue(), $rate->withCurrency($btc)->rate($usd)); + $expectedValue = app(Mathable::class)->mul($expected->getValue(), 100); + self::assertEquals($expectedValue, $rate->withCurrency($btc)->convertTo($usd)); + self::assertEquals($expected->getValue(), $rate->withCurrency($btc)->rate($usd)); } - } diff --git a/tests/TestCase.php b/tests/TestCase.php index f42cf3b..00143e9 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -4,20 +4,19 @@ use Bavix\Wallet\WalletServiceProvider; use Bavix\WalletSwap\RateServiceProvider; -use Orchestra\Testbench\TestCase as OrchestraTestCase; use Illuminate\Foundation\Application; +use Orchestra\Testbench\TestCase as OrchestraTestCase; use Swap\Laravel\SwapServiceProvider; class TestCase extends OrchestraTestCase { - /** * @return void */ public function setUp(): void { parent::setUp(); - $this->artisan('migrate', ['--database' => 'testbench'])->run(); + $this->artisan('migrate')->run(); } /** @@ -49,14 +48,5 @@ protected function getEnvironmentSetUp($app): void 'russian_central_bank' => true, 'cryptonator' => true, ]); - - // database - $app['config']->set('database.default', 'testbench'); - $app['config']->set('database.connections.testbench', [ - 'driver' => 'sqlite', - 'database' => ':memory:', - 'prefix' => '', - ]); } - }