PhpUnit Extras

If Your Test Class Needs a SetUp Method

<?php


namespace AKlump\PHPUnit\Test\EasyMock;

use AKlump\PHPUnit\EasyMock;
use AKlump\PHPUnit\EasyMockTrait;
use PHPUnit\Framework\TestCase;

Here is the Test

This shows how you will use setUp by aliasing EasyMockTrait::setUp.

class TestWithSetUpMethodUnitTest extends TestCase {

  use EasyMockTrait {
    EasyMockTrait::setUp as easyMockSetUp;
  }

  protected function getSchema() {
    return [
      'classToBeTested' => "AKlump\PHPUnit\Test\EasyMock\Quebec",
      'classArgumentsMap' => [
        'list' => [['do', 're', 'mi'], EasyMock::VALUE],
      ],
    ];
  }

  public function testTestDataObject() {
    $this->assertSame(['fa', 'so'], $this->data);
    $this->assertSame(['do', 're', 'mi'], $this->obj->getList());
  }

  public function testConstructor() {
    $this->assertConstructorSetsInternalProperties();
  }

  public function setUp() {
    $this->easyMockSetUp();

    $this->data = ['fa', 'so'];
  }

}

Class Being Tested

class Quebec {

  protected $list;

  public function __construct(array $list) {
    $this->list = $list;
  }

  public function getList() {
    return $this->list;
  }

}