Contao\CoreBundle\Test\TestCase::mockConfigAdapter PHP Method

mockConfigAdapter() protected method

Mocks a config adapter.
protected mockConfigAdapter ( integer | null $minPasswordLength = null ) : Adapter | PHPUnit_Framework_MockObject_MockObject
$minPasswordLength integer | null
return Contao\CoreBundle\Framework\Adapter | PHPUnit_Framework_MockObject_MockObject
    protected function mockConfigAdapter($minPasswordLength = null)
    {
        $configAdapter = $this->getMockBuilder('Contao\\CoreBundle\\Framework\\Adapter')->setMethods(['isComplete', 'preload', 'getInstance', 'get'])->disableOriginalConstructor()->getMock();
        $configAdapter->expects($this->any())->method('isComplete')->willReturn(true);
        $configAdapter->expects($this->any())->method('preload')->willReturn(null);
        $configAdapter->expects($this->any())->method('getInstance')->willReturn(null);
        $configAdapter->expects($this->any())->method('get')->willReturnCallback(function ($key) use($minPasswordLength) {
            switch ($key) {
                case 'characterSet':
                    return 'UTF-8';
                case 'timeZone':
                    return 'Europe/Berlin';
                case 'gdMaxImgWidth':
                case 'gdMaxImgHeight':
                    return 3000;
                case 'minPasswordLength':
                    return $minPasswordLength;
                default:
                    return null;
            }
        });
        return $configAdapter;
    }