/** * @covers ::onClass * @expectedException GanbaroDigital\UnitTestHelpers\V1\Exceptions\MethodIsNotStatic */ public function testCanOnlyCallStaticMethodsByClass() { // ---------------------------------------------------------------- // perform the change InvokeMethod::onClass(InvokeMethodTest_TargetClass::class, 'publicMethod', []); }
/** * @coversNone */ public function testSupportsIndependentCaches() { // ---------------------------------------------------------------- // setup your test // make sure we start with a known state InvokeMethod::onClass(CacheTypeA::class, 'resetCache'); InvokeMethod::onClass(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::onClass(CacheTypeA::class, 'setInCache', [$key, $value]); } foreach ($expectedResultsB as $key => $value) { InvokeMethod::onClass(CacheTypeB::class, 'setInCache', [$key, $value]); } // ---------------------------------------------------------------- // test the results $actualResultsA = InvokeMethod::onClass(CacheTypeA::class, 'getCache'); $actualResultsB = InvokeMethod::onClass(CacheTypeB::class, 'getCache'); $this->assertEquals($expectedResultsA, $actualResultsA); $this->assertEquals($expectedResultsB, $actualResultsB); }