Contao\CoreBundle\Test\Contao\WidgetTest::testGetPost PHP Method

testGetPost() public method

Tests the getPost() method.
public testGetPost ( string $key, string $input, mixed $value, string $expected )
$key string
$input string
$value mixed
$expected string
    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);
    }