public function testGetPost($key, $input, $value, $expected) { // Prevent "undefined index" errors $errorReporting = error_reporting(); error_reporting($errorReporting & ~E_NOTICE); $widget = $this->getMock('Contao\\Widget'); $class = new \ReflectionClass('Contao\\Widget'); $method = $class->getMethod('getPost'); $method->setAccessible(true); $_POST[$input] = $value; Input::resetCache(); Input::initialize(); $this->assertEquals($expected, $method->invoke($widget, $key)); // Restore the error reporting level error_reporting($errorReporting); }