PHPackages                             lukeraymonddowning/pest-plugin-money - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. lukeraymonddowning/pest-plugin-money

ActiveLibrary[Framework](/categories/framework)

lukeraymonddowning/pest-plugin-money
====================================

A Pest PHP plugin that makes testing popular Money packages easy.

v1.1.0(4y ago)2069.8k3[1 PRs](https://github.com/lukeraymonddowning/pest-plugin-money/pulls)MITPHPPHP ^7.3 || ^8.0 || ^8.1

Since May 21Pushed 3y ago1 watchersCompare

[ Source](https://github.com/lukeraymonddowning/pest-plugin-money)[ Packagist](https://packagist.org/packages/lukeraymonddowning/pest-plugin-money)[ GitHub Sponsors](https://github.com/lukeraymonddowning)[ RSS](/packages/lukeraymonddowning-pest-plugin-money/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (8)Versions (5)Used By (0)

pest-plugin-money
=================

[](#pest-plugin-money)

This package is a plugin for [Pest PHP](https://pestphp.com). It allows you to write tests against monetary values provided by either [brick/money](https://github.com/brick/money), [moneyphp/money](https://github.com/moneyphp/money) or [archtechx/money](https://github.com/archtechx/money)using the same declarative syntax you're used to with Pest's expectation syntax.

Installation
------------

[](#installation)

To get started, install the plugin using composer:

```
composer require lukeraymonddowning/pest-plugin-money --dev
```

This package requires the following:

- Pest PHP
- Either the Brick Money, MoneyPHP or Archtech Money libraries
- PHP 7.3 or greater

Usage
-----

[](#usage)

Using the plugin is simple! Here are examples of the expectations made available by this plugin. We will use Brick Money for all of our examples, but they work exactly the same with MoneyPHP.

### toBeMoney

[](#tobemoney)

To simply assert that an object is a monetary value, use the `toBeMoney` method:

```
expect(Money::of(100, "GBP"))->toBeMoney();
expect("Hello World")->not->toBeMoney();
```

### toCost

[](#tocost)

To check that a monetary value is equal to a certain amount, use the `toCost` method:

```
expect(Money::of(150, "GBP"))->toCost(150, 'GBP');
expect(Money::of(150, "GBP"))->toCost($anotherMoneyObject);
expect(Money::of(150, "GBP"))->not->toCost(100, 'GBP');
```

### toCostLessThan

[](#tocostlessthan)

To check that a monetary value is less than a certain amount, use the `toCostLessThan` method:

```
expect(Money::of(150, "GBP"))->toCostLessThan(160, 'GBP');
expect(Money::of(150, "GBP"))->toCostLessThan($anotherMoneyObject);
expect(Money::of(150, "GBP"))->not->toCostLessThan(140, 'GBP');
```

### toCostMoreThan

[](#tocostmorethan)

To check that a monetary value is more than a certain amount, use the `toCostMoreThan` method:

```
expect(Money::of(150, "GBP"))->toCostMoreThan(140, 'GBP');
expect(Money::of(150, "GBP"))->toCostMoreThan($anotherMoneyObject);
expect(Money::of(150, "GBP"))->not->toCostMoreThan(160, 'GBP');
```

Choosing a money library
------------------------

[](#choosing-a-money-library)

This package will attempt to autodetect which of the supported money libraries you have installed. If you want to enforce which library to use, you can call the `useMoneyLibrary` function. Pass the class name of the relevant money package:

```
useMoneyLibrary(\Money\Money::class); // Use the MoneyPHP library
useMoneyLibrary(\Brick\Money\Money::class); // Use the Brick Money library
useMoneyLibrary(\ArchTech\Money\Money::class); // Use the Archtech Money library
```

Setting a default currency
--------------------------

[](#setting-a-default-currency)

If your application primarily uses a single currency, it can be annoying having to declare it as the second argument for each expectation. By setting a default, you can omit the currency and just provide the amount:

```
useCurrency('GBP');
expect($money)->toCost('100'); // Uses Great British Pounds

useCurrency('USD');
expect($money)->toCost('100'); // Uses US Dollars
```

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~60 days

Total

4

Last Release

1636d ago

Major Versions

0.2.0 → v1.0.02021-07-26

PHP version history (2 changes)v0.1.0PHP ^7.3 || ^8.0

v1.1.0PHP ^7.3 || ^8.0 || ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/139db346fa173a79481af05b0455e2e8ad7d2ab594c7f53bde3522a3dfeeaf25?d=identicon)[96downlu](/maintainers/96downlu)

---

Top Contributors

[![lukeraymonddowning](https://avatars.githubusercontent.com/u/12202279?v=4)](https://github.com/lukeraymonddowning "lukeraymonddowning (23 commits)")

---

Tags

phpplugintestingunitframeworktestpest

###  Code Quality

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/lukeraymonddowning-pest-plugin-money/health.svg)

```
[![Health](https://phpackages.com/badges/lukeraymonddowning-pest-plugin-money/health.svg)](https://phpackages.com/packages/lukeraymonddowning-pest-plugin-money)
```

###  Alternatives

[defstudio/pest-plugin-laravel-expectations

A plugin to add laravel tailored expectations to Pest

98548.9k4](/packages/defstudio-pest-plugin-laravel-expectations)[pestphp/pest-plugin-stressless

Stressless plugin for Pest

67792.6k16](/packages/pestphp-pest-plugin-stressless)[jonpurvis/lawman

A PestPHP Plugin to help with architecture testing SaloonPHP integrations

4027.7k8](/packages/jonpurvis-lawman)[spatie/pest-plugin-route-testing

Make sure all routes in your Laravel app are ok

13753.8k](/packages/spatie-pest-plugin-route-testing)[milroyfraser/pest-plugin-gwt

Given When Then(GWT) Plugin for Pest

10332.1k1](/packages/milroyfraser-pest-plugin-gwt)[ozzie/pest-plugin-nest

Nest Pest PHP tests for better organization and readability

2028.3k](/packages/ozzie-pest-plugin-nest)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
