Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-developer
Test
Unit
Console
Command
ProfilerEnableCommandTest.php
Go to the documentation of this file.
1
<?php
7
namespace
Magento\Developer\Test\Unit\Console\Command
;
8
9
use
Magento\Developer\Console\Command\ProfilerEnableCommand
;
10
use
Magento\Framework\Filesystem\Io\File
;
11
use PHPUnit\Framework\TestCase;
12
use Symfony\Component\Console\Tester\CommandTester;
13
19
class
ProfilerEnableCommandTest
extends
TestCase
20
{
24
private
$filesystemMock;
25
34
public
function
testCommand(
string
$inputType,
bool
$fileExists,
string
$expectedOutput)
35
{
36
$this->filesystemMock
37
->expects($this->once())
38
->method(
'write'
)
39
->with(
40
BP
.
'/'
.
ProfilerEnableCommand::PROFILER_FLAG_FILE
,
41
$inputType ?:
ProfilerEnableCommand::TYPE_DEFAULT
42
);
43
$this->filesystemMock
44
->expects($this->once())
45
->method(
'fileExists'
)
46
->with(
BP
.
'/'
.
ProfilerEnableCommand::PROFILER_FLAG_FILE
)
47
->willReturn($fileExists);
49
$command =
new
ProfilerEnableCommand
($this->filesystemMock);
50
$commandTester =
new
CommandTester($command);
51
$commandTester->execute([
'type'
=> $inputType]);
52
53
self::assertEquals(
54
$expectedOutput,
55
trim(str_replace(PHP_EOL,
' '
, $commandTester->getDisplay()))
56
);
57
}
58
64
public
function
commandDataProvider
()
65
{
66
return
[
67
[
68
''
,
69
true
,
70
'Profiler enabled with html output.'
71
],
72
[
73
''
,
74
false
,
75
'Something went wrong while enabling the profiler.'
76
],
77
[
78
'html'
,
79
true
,
80
'Profiler enabled with html output.'
81
],
82
[
83
'html'
,
84
false
,
85
'Something went wrong while enabling the profiler.'
86
],
87
[
88
'csvfile'
,
89
true
,
90
'Profiler enabled with csvfile output. Output will be saved in /var/log/profiler.csv'
91
],
92
[
93
'csvfile'
,
94
false
,
95
'Something went wrong while enabling the profiler.'
96
],
97
[
98
'xml'
,
99
true
,
100
'Type xml is not one of the built-in output types (html, csvfile). '
.
101
'Profiler enabled with xml output.'
102
],
103
[
104
'xml'
,
105
false
,
106
'Type xml is not one of the built-in output types (html, csvfile). '
.
107
'Something went wrong while enabling the profiler.'
108
],
109
];
110
}
111
115
protected
function
setUp
()
116
{
117
$this->filesystemMock = $this->getMockBuilder(File::class)
118
->disableOriginalConstructor()
119
->getMock();
120
}
121
}
Magento\Developer\Test\Unit\Console\Command\ProfilerEnableCommandTest
Definition:
ProfilerEnableCommandTest.php:19
Magento\Developer\Console\Command\ProfilerEnableCommand\TYPE_DEFAULT
const TYPE_DEFAULT
Definition:
ProfilerEnableCommand.php:25
Magento\Developer\Console\Command\ProfilerEnableCommand
Definition:
ProfilerEnableCommand.php:15
Magento\Developer\Console\Command\ProfilerEnableCommand\PROFILER_FLAG_FILE
const PROFILER_FLAG_FILE
Definition:
ProfilerEnableCommand.php:20
Magento\Developer\Test\Unit\Console\Command
Definition:
ProfilerDisableCommandTest.php:7
BP
const BP
Definition:
autoload.php:14
Magento\Developer\Test\Unit\Console\Command\ProfilerEnableCommandTest\commandDataProvider
commandDataProvider()
Definition:
ProfilerEnableCommandTest.php:64
Magento\Developer\Test\Unit\Console\Command\ProfilerEnableCommandTest\setUp
setUp()
Definition:
ProfilerEnableCommandTest.php:115
Magento\Framework\Filesystem\Io\File
Definition:
File.php:12