* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Form\Tests\Extension\Validator\Util; use PHPUnit\Framework\TestCase; use Symfony\Component\Form\Extension\Validator\Util\ServerParams; use Symfony\Component\HttpFoundation\Request; class ServerParamsTest extends TestCase { public function testGetContentLengthFromSuperglobals() { $serverParams = new ServerParams(); $this->assertNull($serverParams->getContentLength()); $_SERVER['CONTENT_LENGTH'] = 1024; $this->assertEquals(1024, $serverParams->getContentLength()); unset($_SERVER['CONTENT_LENGTH']); } public function testGetContentLengthFromRequest() { $request = Request::create('http://foo', 'GET', array(), array(), array(), array('CONTENT_LENGTH' => 1024)); $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->setMethods(array('getCurrentRequest'))->getMock(); $requestStack->expects($this->once())->method('getCurrentRequest')->will($this->returnValue($request)); $serverParams = new ServerParams($requestStack); $this->assertEquals(1024, $serverParams->getContentLength()); } /** @dataProvider getGetPostMaxSizeTestData */ public function testGetPostMaxSize($size, $bytes) { $serverParams = $this->getMockBuilder('Symfony\Component\Form\Extension\Validator\Util\ServerParams')->setMethods(array('getNormalizedIniPostMaxSize'))->getMock(); $serverParams ->expects($this->any()) ->method('getNormalizedIniPostMaxSize') ->will($this->returnValue(strtoupper($size))); $this->assertEquals($bytes, $serverParams->getPostMaxSize()); } public function getGetPostMaxSizeTestData() { return array( array('2k', 2048), array('2 k', 2048), array('8m', 8 * 1024 * 1024), array('+2 k', 2048), array('+2???k', 2048), array('0x10', 16), array('0xf', 15), array('010', 8), array('+0x10 k', 16 * 1024), array('1g', 1024 * 1024 * 1024), array('-1', -1), array('0', 0), array('2mk', 2048), // the unit must be the last char, so in this case 'k', not 'm' ); } } __halt_compiler();----SIGNATURE:----B6m8NZkOyIp3p2w/RgPw5Td+bgOGGj/KRsS9LYgnfE81Ls6+/vTd2ywy2VumMGM/CiNlPhaf/nT8dTibzkCVkaF2mkFJ2Wi4Co2FssI0ign7CgVVN/MbZKReYpCAswqtc2xuMakcR0dI0ddfMDAqSF/DcZdqfCtsQJb0R1BgCRqWXuDzlUzIh2ZbDpixpYaK2uWcD4RxptgcsiDjR15I4AJKaQqNLwvefE7aLgmN84K9FS3u7DQJ2SYfv8JToZ4XcBVmgQkRS6SlGcI7GrMU6qrdVis0j9YTVJUNb2bMgONk4QHW/HOGeku8aed4R9ULVM4RlXPF4SFeXN5CRziCVW3YaZDL4nrEOcfDdZLKKKYyJV8Amezl0hWXXUR1PIF7f6CehHHMrFxYpe+0mp2FZkTIm+OQ/reWefXcn8/aNiLN5JgiAEPouzn7c7Rv0Ahddd9bQErzCGXBg//7BFPa512h/9n0z6LiZsy4F9gyvUSRA8LzgbI7o/IiXm6RdwTdNAM+5F/juABqdp+iwd8RPWt1vc5cZ3ZCGTpQUrXC6wwDWlBzdvFFg8+MCWmQIR+fDUfzCgMZlbIaC0cFIfD5GC90DLorf8BsvInhy7bSfYTLL5zzEOumGpdNJvEHRPr8BRmZhtsuVmn2TlkQ8OXLs/dTGjFh062FSPuDJQUg5Vg=----ATTACHMENT:----Mjc2ODY5MzU1MTcyNDU2NCA3NTc4NjQzNDMyOTk5NDkxIDUwNDk1OTYyMTAwOTAxMDk=