Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions
MemoryLimitTest Class Reference
Inheritance diagram for MemoryLimitTest:

Public Member Functions

 testPrintHeader ()
 
 testPrintStats ()
 
 testValidateUsage ()
 
 testValidateUsageException ()
 

Protected Member Functions

 _createObject ($memCap, $leakCap)
 

Detailed Description

Definition at line 8 of file MemoryLimitTest.php.

Member Function Documentation

◆ _createObject()

_createObject (   $memCap,
  $leakCap 
)
protected
Parameters
string$memCap
string$leakCap
Returns
\Magento\TestFramework\MemoryLimit

Definition at line 54 of file MemoryLimitTest.php.

55  {
56  $helper = $this->createPartialMock(\Magento\TestFramework\Helper\Memory::class, ['getRealMemoryUsage']);
57  $helper->expects($this->any())->method('getRealMemoryUsage')->will($this->returnValue(1024 * 1024));
58  return new \Magento\TestFramework\MemoryLimit($memCap, $leakCap, $helper);
59  }
$helper
Definition: iframe.phtml:13

◆ testPrintHeader()

testPrintHeader ( )

Definition at line 10 of file MemoryLimitTest.php.

11  {
13  $this->assertNotEmpty($result);
14  $this->assertStringEndsWith(PHP_EOL, $result);
15  }

◆ testPrintStats()

testPrintStats ( )

Definition at line 17 of file MemoryLimitTest.php.

18  {
19  $object = $this->_createObject(0, 0);
20  $result = $object->printStats();
21  $this->assertContains('Memory usage (OS):', $result);
22  $this->assertContains('1.00M', $result);
23  $this->assertContains('Estimated memory leak:', $result);
24  $this->assertContains('reported by PHP', $result);
25  $this->assertStringEndsWith(PHP_EOL, $result);
26 
27  $object = $this->_createObject('2M', 0);
28  $this->assertContains('50.00% of configured 2.00M limit', $object->printStats());
29 
30  $object = $this->_createObject(0, '500K');
31  $this->assertContains('% of configured 0.49M limit', $object->printStats());
32  }
_createObject($memCap, $leakCap)

◆ testValidateUsage()

testValidateUsage ( )

Definition at line 34 of file MemoryLimitTest.php.

35  {
36  $object = $this->_createObject(0, 0);
37  $this->assertNull($object->validateUsage());
38  }
_createObject($memCap, $leakCap)

◆ testValidateUsageException()

testValidateUsageException ( )

@expectedException \LogicException

Definition at line 43 of file MemoryLimitTest.php.

44  {
45  $object = $this->_createObject('500K', '2M');
46  $object->validateUsage();
47  }
_createObject($memCap, $leakCap)

The documentation for this class was generated from the following file: