From 3c2843d7dc38e9d88f68ecf58574b57bb7c2e16e Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Mon, 27 Sep 2021 12:42:42 +0100 Subject: [PATCH] Install money formatter dependency, and add failing test --- composer.json | 3 +- composer.lock | 67 ++++++++++++++++++++++++++++++++++++++++++++- tests/ModelTest.php | 8 ++++++ 3 files changed, 76 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index e667b25..22ede2a 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,8 @@ "php": "^7.2|^8.0", "illuminate/contracts": "^6.0 || ^7.0 || ^8.0", "illuminate/database": "^6.0 || ^7.0 || ^8.40.0", - "illuminate/support": "^6.0 || ^7.0 || ^8.0" + "illuminate/support": "^6.0 || ^7.0 || ^8.0", + "akaunting/laravel-money": "^1.2" }, "require-dev": { "orchestra/testbench": "^6.2", diff --git a/composer.lock b/composer.lock index 6f07664..6358691 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,73 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2ad5f8a066d9668ecb6fdef66c7fda99", + "content-hash": "aff20e51e1b3b3407a7d6fca58c2541b", "packages": [ + { + "name": "akaunting/laravel-money", + "version": "1.2.2", + "source": { + "type": "git", + "url": "https://github.com/akaunting/laravel-money.git", + "reference": "a60cd786ac85e290ff1fa62b104ae04df2dcbd30" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/akaunting/laravel-money/zipball/a60cd786ac85e290ff1fa62b104ae04df2dcbd30", + "reference": "a60cd786ac85e290ff1fa62b104ae04df2dcbd30", + "shasum": "" + }, + "require": { + "illuminate/support": ">=5.4", + "illuminate/view": ">=5.4", + "php": ">=5.6.4" + }, + "require-dev": { + "mockery/mockery": ">=1.0", + "phpunit/phpunit": ">=5.7" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Akaunting\\Money\\Provider" + ] + } + }, + "autoload": { + "psr-4": { + "Akaunting\\Money\\": "./src" + }, + "files": [ + "src/helpers.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Denis Duliçi", + "email": "info@akaunting.com", + "homepage": "https://akaunting.com", + "role": "Developer" + } + ], + "description": "Currency formatting and conversion package for Laravel", + "keywords": [ + "convert", + "currency", + "format", + "laravel", + "money" + ], + "support": { + "issues": "https://github.com/akaunting/laravel-money/issues", + "source": "https://github.com/akaunting/laravel-money/tree/1.2.2" + }, + "time": "2021-05-19T19:42:05+00:00" + }, { "name": "brick/math", "version": "0.9.2", diff --git a/tests/ModelTest.php b/tests/ModelTest.php index e22d6cd..457a49d 100644 --- a/tests/ModelTest.php +++ b/tests/ModelTest.php @@ -3,6 +3,7 @@ namespace Squire\Tests; use Illuminate\Support\Facades\App; +use Squire\Models\Currency; use Squire\Repository; use Squire\Tests\Models; @@ -40,6 +41,13 @@ public function can_translate_models() $this->assertEquals('es', Models\Foo::first()->lang); } + /** @test */ + public function can_format_usd() + { + $this->assertSame('$5.00', Currency::find('usd')->format(500)); + $this->assertSame('$500.00', Currency::find('usd')->format(500, true)); + } + protected function testModel($model) { $locales = array_keys(Repository::getSources($model));