/** * @covers DataSift\Storyplayer\Output::logVardump() */ public function testCanLogVardump() { // ---------------------------------------------------------------- // setup the test $name = 'msg'; $msg = "this is an emergency, damnit!"; $plugin1 = Mockery::mock("DataSift\\Storyplayer\\OutputLib\\OutputPlugin"); $plugin1->shouldReceive('logVardump')->once()->with($name, $msg); $plugin2 = Mockery::mock("DataSift\\Storyplayer\\OutputLib\\OutputPlugin"); $plugin2->shouldReceive('logVardump')->once()->with($name, $msg); $obj = new Output(); $obj->usePluginInSlot($plugin1, "console"); $obj->usePluginInSlot($plugin2, "slot1"); // ---------------------------------------------------------------- // perform the change $obj->logVardump($name, $msg); // ---------------------------------------------------------------- // test the results Mockery::close(); }
/** * * @return \DataSift\Stone\ObjectLib\BaseObject */ public function loadRuntimeConfig(Output $output) { // where is the config file? $configDir = $this->getConfigDir(); $filename = $configDir . "/" . self::RUNTIME_FILENAME; // does the file exist? if (!is_file($filename)) { return new BaseObject(); } // at this point, we should be able to load the config $raw = @file_get_contents($filename); if (FALSE === $raw) { $output->logCliError("unable to read config file '{$filename}'; permissions error?"); exit(1); } // the config file may be empty if (strlen(rtrim($raw)) === 0) { return new BaseObject(); } $config = @json_decode($raw); if (NULL === $config) { $output->logCliError("unable to parse JSON in config file '{$filename}'"); exit(1); } // we need to convert the loaded config into our more powerful config // (at least for now) $enhancedConfig = new BaseObject(); $enhancedConfig->mergeFrom($config); // all done return $enhancedConfig; }