Index

PHPUnit Extras

phpunit_extras

Summary

Classes to extend \PHPUnit_Framework_TestCase.

Quick Start

composer require aklump/phpunit-extras

Contributing

If you find this project useful... please consider making a donation.

Usage

Test a Class With String Arguments

In this example the class being tested only takes string arguments, so there is no mocking involved. Here's how you would set that up.

<?php

class Foo {

  protected $schema = [
    'classToBeTested' => MyClassToBeTested::class,

    // You still need to defined the properties, which the constructor should set, but the values are null, indicating there is no automatic mocking.
    'classArgumentsMap' => [
      'alpha' => NULL,
      'bravo' => NULL,
    ],
  ];

  public function testSomething() {

    // You hard code the argument values here.
    $this->args->alpha = 'lorem';
    $this->args->bravo = 'ipsum';

    // The create the object before any asserts.
    $this->createObj();

   ... one or more assertions.
  }

}