Skip to content

Commit 6aa6bd4

Browse files
committed
Update Integration Test Memory helper coding style and unit tests
1 parent faafb28 commit 6aa6bd4

File tree

2 files changed

+20
-14
lines changed
  • dev/tests/integration/framework

2 files changed

+20
-14
lines changed

dev/tests/integration/framework/Magento/TestFramework/Helper/Memory.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
*/
1111
namespace Magento\TestFramework\Helper;
1212

13+
/**
14+
* Integration Test Framework memory management logic.
15+
*/
1316
class Memory
1417
{
1518
/**
@@ -38,9 +41,9 @@ public function __construct(\Magento\Framework\Shell $shell)
3841
/**
3942
* Retrieve the effective memory usage of the current process
4043
*
41-
* memory_get_usage() cannot be used because of the bug
42-
* @link https://bugs.php.net/bug.php?id=62467
44+
* Function memory_get_usage() cannot be used because of the bug
4345
*
46+
* @link https://bugs.php.net/bug.php?id=62467
4447
* @return int Memory usage in bytes
4548
*/
4649
public function getRealMemoryUsage()
@@ -100,6 +103,7 @@ protected function _getWinProcessMemoryUsage($pid)
100103
* @return int
101104
* @throws \InvalidArgumentException
102105
* @throws \OutOfBoundsException
106+
* phpcs:ignore Magento2.Functions.StaticFunction
103107
*/
104108
public static function convertToBytes($number)
105109
{
@@ -132,9 +136,10 @@ public static function convertToBytes($number)
132136
* - but the value has only one delimiter, such as "234,56", then it is impossible to know whether it is decimal
133137
* separator or not. Only knowing the right format would allow this.
134138
*
135-
* @param $number
139+
* @param string $number
136140
* @return string
137141
* @throws \InvalidArgumentException
142+
* phpcs:ignore Magento2.Functions.StaticFunction
138143
*/
139144
protected static function _convertToNumber($number)
140145
{
@@ -152,6 +157,7 @@ protected static function _convertToNumber($number)
152157
*
153158
* @link http://php.net/manual/en/function.php-uname.php
154159
* @return boolean
160+
* phpcs:ignore Magento2.Functions.StaticFunction
155161
*/
156162
public static function isMacOs()
157163
{

dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Helper/MemoryTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,7 @@ public function testGetRealMemoryUsageUnix()
2121
{
2222
$object = new \Magento\TestFramework\Helper\Memory($this->_shell);
2323
$this->_shell->expects(
24-
$this->at(0)
25-
)->method(
26-
'execute'
27-
)->with(
28-
$this->stringStartsWith('tasklist.exe ')
29-
)->will(
30-
$this->throwException(new \Magento\Framework\Exception\LocalizedException(__('command not found')))
31-
);
32-
$this->_shell->expects(
33-
$this->at(1)
24+
$this->once()
3425
)->method(
3526
'execute'
3627
)->with(
@@ -44,7 +35,16 @@ public function testGetRealMemoryUsageUnix()
4435
public function testGetRealMemoryUsageWin()
4536
{
4637
$this->_shell->expects(
47-
$this->once()
38+
$this->at(0)
39+
)->method(
40+
'execute'
41+
)->with(
42+
$this->stringStartsWith('ps ')
43+
)->will(
44+
$this->throwException(new \Magento\Framework\Exception\LocalizedException(__('command not found')))
45+
);
46+
$this->_shell->expects(
47+
$this->at(1)
4848
)->method(
4949
'execute'
5050
)->with(

0 commit comments

Comments
 (0)