private function setThisPiwikUrl($thisUrl) { $mock = $this->getMock('stdClass', array('getValue')); $mock->expects($this->any())->method('getValue')->willReturnCallback(function ($key) use($thisUrl) { if ($key == SettingsPiwik::OPTION_PIWIK_URL) { return $thisUrl; } else { return "..."; } }); Option::setSingletonInstance($mock); }