/** * @covers ::lookupMethodFor */ public function testReturnsFallbackWhenNothingMatches() { // ---------------------------------------------------------------- // setup your test $data = "hello"; $map = []; $expectedResult = "nothingMatchesTheInputType"; // ---------------------------------------------------------------- // perform the change $actualResult = InvokeMethod::onClass(LookupMethodByType_TestObject::class, 'lookupMethodFor', [$data, $map]); // ---------------------------------------------------------------- // test the results $this->assertEquals($expectedResult, $actualResult); }
/** * @covers ::getCacheKey */ public function testUsesClassNameForObjectKeyIntoStaticCache() { // ---------------------------------------------------------------- // setup your test $data = new stdClass(); $expectedResult = get_class($data); // ---------------------------------------------------------------- // perform the change // ---------------------------------------------------------------- // test the results $actualResult = InvokeMethod::onClass(IsTraversable::class, 'getCacheKey', [$data]); $this->assertEquals($expectedResult, $actualResult); }
/** * @covers ::splitPathInTwo */ public function testInternallySplitsAPathIntoParentAndChild() { // ---------------------------------------------------------------- // setup your test $path = "dot.notation.support"; $expectedResult = ['dot.notation', 'support']; // ---------------------------------------------------------------- // perform the change $actualResult = InvokeMethod::onClass(MergeUsingDotNotationPath::class, 'splitPathInTwo', [$path]); // ---------------------------------------------------------------- // test the results $this->assertEquals($expectedResult, $actualResult); }
/** * @covers ::getPartFromObject * @covers ::getExtension */ public function testCanExtendObjectUsingClassname() { // ---------------------------------------------------------------- // setup your test $obj = (object) ["one" => 1, "two" => 2]; $expectedResult = new stdClass(); // ---------------------------------------------------------------- // perform the change $actualResult = InvokeMethod::onClass(DescendDotNotationPath::class, 'getPartFromObject', [$obj, "three", stdClass::class]); // ---------------------------------------------------------------- // test the results $this->assertEquals($expectedResult, $actualResult); $this->assertTrue(isset($obj->three)); $this->assertTrue($obj->three instanceof stdClass); }