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

Public Member Functions

 testConstructorException ()
 
 testDisplayStats ()
 
 testActivateStatsDisplaying ()
 
 testActivateLimitValidation ()
 

Protected Member Functions

 setUp ()
 
 tearDown ()
 

Protected Attributes

 $_object
 
 $_memoryLimit
 
 $_activationPolicy
 

Detailed Description

Definition at line 12 of file MemoryTest.php.

Member Function Documentation

◆ setUp()

setUp ( )
protected

Definition at line 29 of file MemoryTest.php.

30  {
31  $this->_memoryLimit = $this->createPartialMock(\Magento\TestFramework\MemoryLimit::class, ['printStats']);
32  $this->_activationPolicy = $this->createPartialMock(\stdClass::class, ['register_shutdown_function']);
33  $this->_object = new \Magento\TestFramework\Bootstrap\Memory(
34  $this->_memoryLimit,
35  [$this->_activationPolicy, 'register_shutdown_function']
36  );
37  }

◆ tearDown()

tearDown ( )
protected

Definition at line 39 of file MemoryTest.php.

40  {
41  $this->_memoryLimit = null;
42  $this->_activationPolicy = null;
43  $this->_object = null;
44  }

◆ testActivateLimitValidation()

testActivateLimitValidation ( )

Definition at line 81 of file MemoryTest.php.

82  {
83  $this->_activationPolicy->expects(
84  $this->once()
85  )->method(
86  'register_shutdown_function'
87  )->with(
88  $this->identicalTo([$this->_memoryLimit, 'validateUsage'])
89  );
90  $this->_object->activateLimitValidation();
91  }

◆ testActivateStatsDisplaying()

testActivateStatsDisplaying ( )

Definition at line 69 of file MemoryTest.php.

70  {
71  $this->_activationPolicy->expects(
72  $this->once()
73  )->method(
74  'register_shutdown_function'
75  )->with(
76  $this->identicalTo([$this->_object, 'displayStats'])
77  );
78  $this->_object->activateStatsDisplaying();
79  }

◆ testConstructorException()

testConstructorException ( )

@expectedException \InvalidArgumentException @expectedExceptionMessage Activation policy is expected to be a callable.

Definition at line 50 of file MemoryTest.php.

51  {
52  new \Magento\TestFramework\Bootstrap\Memory($this->_memoryLimit, 'non_existing_callable');
53  }

◆ testDisplayStats()

testDisplayStats ( )

Definition at line 55 of file MemoryTest.php.

56  {
57  $eol = PHP_EOL;
58  $this->expectOutputString("{$eol}=== Memory Usage System Stats ==={$eol}Dummy Statistics{$eol}");
59  $this->_memoryLimit->expects(
60  $this->once()
61  )->method(
62  'printStats'
63  )->will(
64  $this->returnValue('Dummy Statistics')
65  );
66  $this->_object->displayStats();
67  }

Field Documentation

◆ $_activationPolicy

$_activationPolicy
protected

Definition at line 27 of file MemoryTest.php.

◆ $_memoryLimit

$_memoryLimit
protected

Definition at line 22 of file MemoryTest.php.

◆ $_object

$_object
protected

Definition at line 17 of file MemoryTest.php.


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