public function setup()
 {
     // AllMatchingTypesList is backed by a static cache
     //
     // we need to make sure that it is empty at the start of every
     // test
     InvokeMethod::onString(AllMatchingTypesList::class, 'resetCache');
 }
 /**
  * @covers ::buildListOfObjectMethods
  */
 public function testBuildsAListOfNonStaticMethodsWhenExaminingAnObject()
 {
     // ----------------------------------------------------------------
     // setup your test
     $expectedMethods = ['objectMethod1' => 'objectMethod1'];
     // ----------------------------------------------------------------
     // perform the change
     $actualMethods = InvokeMethod::onString(CallableMethodsList::class, 'buildListOfObjectMethods', [new CallableMethodsListTest_Target1()]);
     // ----------------------------------------------------------------
     // test the results
     $this->assertEquals($expectedMethods, $actualMethods);
 }
 /**
  * @coversNone
  */
 public function testSupportsIndependentCaches()
 {
     // ----------------------------------------------------------------
     // setup your test
     // make sure we start with a known state
     InvokeMethod::onString(CacheTypeA::class, 'resetCache');
     InvokeMethod::onString(CacheTypeB::class, 'resetCache');
     // we expect CacheTypeA to ONLY have these values
     $expectedResultsA = ['harry', 'sally', 'fred'];
     // we expect CacheTypeB to ONLY have these values
     $expectedResultsB = ['cod', 'haddock', 'trout'];
     // ----------------------------------------------------------------
     // perform the change
     foreach ($expectedResultsA as $key => $value) {
         InvokeMethod::onString(CacheTypeA::class, 'setInCache', [$key, $value]);
     }
     foreach ($expectedResultsB as $key => $value) {
         InvokeMethod::onString(CacheTypeB::class, 'setInCache', [$key, $value]);
     }
     // ----------------------------------------------------------------
     // test the results
     $actualResultsA = InvokeMethod::onString(CacheTypeA::class, 'getCache');
     $actualResultsB = InvokeMethod::onString(CacheTypeB::class, 'getCache');
     $this->assertEquals($expectedResultsA, $actualResultsA);
     $this->assertEquals($expectedResultsB, $actualResultsB);
 }
 /**
  * @covers ::onClass
  * @covers ::onString
  * @expectedException GanbaroDigital\UnitTestHelpers\Exceptions\E4xx_MethodIsNotStatic
  */
 public function testCanOnlyCallStaticMethodsByClass()
 {
     // ----------------------------------------------------------------
     // perform the change
     InvokeMethod::onString(InvokeMethodTest_TargetClass::class, 'publicMethod', []);
 }
 /**
  * @covers ::findMethodToCall
  * @covers ::findFirstMatchingMethod
  * @expectedException GanbaroDigital\Reflection\Exceptions\E4xx_UnsupportedType
  */
 public function testThrowsAnExceptionWhenNoMatchFound()
 {
     // ----------------------------------------------------------------
     // setup your test
     $data = 100;
     $target = new FirstMethodMatchingTypeTest_Target2();
     // ----------------------------------------------------------------
     // perform the change
     InvokeMethod::onString(FirstMethodMatchingType::class, 'findMethodToCall', [$data, $target, 'from']);
 }