PHPackages                             digitalrevolution/accessorpair-constraint - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. digitalrevolution/accessorpair-constraint

ActiveLibrary[Testing &amp; Quality](/categories/testing)

digitalrevolution/accessorpair-constraint
=========================================

Digital Revolution PHPUnit Constraint for accessorpairs

v2.8.0(3mo ago)10120.1k↑24.4%10[1 PRs](https://github.com/123inkt/accessorpair-constraint/pulls)7MITPHPPHP &gt;=8.1CI passing

Since Apr 2Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/123inkt/accessorpair-constraint)[ Packagist](https://packagist.org/packages/digitalrevolution/accessorpair-constraint)[ RSS](/packages/digitalrevolution-accessorpair-constraint/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (45)Used By (7)

[![Minimum PHP Version](https://camo.githubusercontent.com/3c4135418454a15848a8a218e20836012cbc0ebf40c09771f9713d88a340ce14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230372e342d383839324246)](https://php.net/)

AccessorPair Constraint
=======================

[](#accessorpair-constraint)

A way to automatically unit test (and cover) all getter and setters of your data class.

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

[](#installation)

```
$ composer require --dev digitalrevolution/accessorpair-constraint

```

Usage
-----

[](#usage)

Once you've imported the AccessorPairAsserter trait into your own test class, or TestCase base class, you can call the `assertAccessorPairs` method to automatically test all your getters/setters.
If you want to keep track of the coverage, configure the PHPUnit annotation to cover all methods of your class.

Optionally, the asserter can also check the initial values of all your class properties and whether or not calling the getter before having called the setter will work.

### Example

[](#example)

```
