wickedone/muppet

This package is abandoned and no longer maintained. No replacement package was suggested.

testing your getters, setters, adders, removers, issers and whatevers

2.0.0 2022-01-10 18:08 UTC

This package is auto-updated.

Last update: 2022-12-29 04:20:07 UTC


README

unit testing your getters, setters, adders, removers, issers and whatevers.

Mutation testing badge Type Coverage codecov PHPStan static analysis coding standards

installation

to add this library to your dev dependencies use

composer require --dev wickedone/muppet

but why?

a lot has been written about the necessity of testing your getters and setters or why it shouldn't been done. from my personal perspective, testing getters and setters provide a stable level of coverage and thus the ability to pin your ci to a minimum coverage value.

what it does

this library doesn't promise to generate perfect, non failing tests out of the box (though it tries). it does however generate test classes which are easy to modify and, most importantly, are compatible with infection (i.e. not too much black magic fuckery).

usage

$config = new Config(
  '~/Code/Project/src',  // base dir
  '~/Code/Project/tests/Unit', // tests dir
  // namespace fragments
  [
    'Awesome',
    'Namespace',
    'Tests',
    'Unit',
  ],
  'foo <bar@qux.com>' // author (optional)
);

(new Generator($config))
  ->generate('MyEntity')
;

assumptions

because we love those...

  • iterable properties use adders and removers rather than setters
  • removers return booleans: true on removal, false otherwise
  • Tests is part of the tests namespace

symfony integration

please see the muppet-bundle