4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\HttpKernel\Tests\DataCollector;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\HttpKernel\DataCollector\MemoryDataCollector;
16 use Symfony\Component\HttpFoundation\Request;
17 use Symfony\Component\HttpFoundation\Response;
19 class MemoryDataCollectorTest extends TestCase
21 public function testCollect()
23 $collector = new MemoryDataCollector();
24 $collector->collect(new Request(), new Response());
26 $this->assertInternalType('integer', $collector->getMemory());
27 $this->assertInternalType('integer', $collector->getMemoryLimit());
28 $this->assertSame('memory', $collector->getName());
31 /** @dataProvider getBytesConversionTestData */
32 public function testBytesConversion($limit, $bytes)
34 $collector = new MemoryDataCollector();
35 $method = new \ReflectionMethod($collector, 'convertToBytes');
36 $method->setAccessible(true);
37 $this->assertEquals($bytes, $method->invoke($collector, $limit));
40 public function getBytesConversionTestData()
45 array('8m', 8 * 1024 * 1024),
47 array('+2???k', 2048),
51 array('+0x10 k', 16 * 1024),
52 array('1g', 1024 * 1024 * 1024),
53 array('1G', 1024 * 1024 * 1024),
56 array('2mk', 2048), // the unit must be the last char, so in this case 'k', not 'm'