expandString($source); return $this->assertEquals($expect, $expanded); } public function stringExpansionData() { return [ [ 'Hello World!', 'Hello World!' ], [ '${testenv}', '' ], [ '${PATH}', getenv("PATH") ], [ 'Greetings ${USER}', 'Greetings '.getenv("USER") ], ]; } /** * @covers ScriptRunner::defineScript * @covers ScriptRunner::evalutateDefinedScript */ public function testDefiningAndCallingScript() { $runner = new ScriptRunner(true); $runner->defineScript('test1', __CLASS__."::call1"); $runner->defineScript('test2', [ __CLASS__."::call2" ]); $this->assertFalse(self::$call1); $runner->evaluateDefinedScript('test1'); $this->assertTrue(self::$call1); $this->assertFalse(self::$call2); $runner->evaluateDefinedScript('test2'); $this->assertTrue(self::$call2); } public static function call1() { self::$call1 = true; } public static function call2() { self::$call2 = true; } private static bool $call1 = false; private static bool $call2 = false; }