7
7
namespace Magento \FunctionalTestingFramework \Extension ;
8
8
9
9
/**
10
- * Class ErrorLogger
10
+ * Class BrowserLogUtil
11
11
* @package Magento\FunctionalTestingFramework\Extension
12
12
*/
13
- class ErrorLogger
13
+ class BrowserLogUtil
14
14
{
15
15
const LOG_TYPE_BROWSER = "browser " ;
16
16
const ERROR_TYPE_JAVASCRIPT = "javascript " ;
17
17
18
- /**
19
- * Error Logger Instance
20
- * @var ErrorLogger
21
- */
22
- private static $ errorLogger ;
23
-
24
- /**
25
- * Singleton method to return ErrorLogger.
26
- * @return ErrorLogger
27
- */
28
- public static function getInstance ()
29
- {
30
- if (!self ::$ errorLogger ) {
31
- self ::$ errorLogger = new ErrorLogger ();
32
- }
33
-
34
- return self ::$ errorLogger ;
35
- }
36
-
37
- /**
38
- * ErrorLogger constructor.
39
- */
40
- private function __construct ()
41
- {
42
- // private constructor
43
- }
44
-
45
18
/**
46
19
* Loops through stepEvent for browser log entries
47
20
*
48
21
* @param \Magento\FunctionalTestingFramework\Module\MagentoWebDriver $module
49
22
* @param \Codeception\Event\StepEvent $stepEvent
50
23
* @return void
51
24
*/
52
- public function logErrors ($ module , $ stepEvent )
25
+ public static function logErrors ($ module , $ stepEvent )
53
26
{
54
27
//Types available should be "server", "browser", "driver". Only care about browser at the moment.
55
28
if (in_array (self ::LOG_TYPE_BROWSER , $ module ->webDriver ->manage ()->getAvailableLogTypes ())) {
56
29
$ browserLogEntries = $ module ->webDriver ->manage ()->getLog (self ::LOG_TYPE_BROWSER );
57
- $ jsErrors = $ this -> getLogsOfType ($ browserLogEntries , self ::ERROR_TYPE_JAVASCRIPT );
30
+ $ jsErrors = self :: getLogsOfType ($ browserLogEntries , self ::ERROR_TYPE_JAVASCRIPT );
58
31
foreach ($ jsErrors as $ entry ) {
59
- $ this -> logError (self ::ERROR_TYPE_JAVASCRIPT , $ stepEvent , $ entry );
32
+ self :: logError (self ::ERROR_TYPE_JAVASCRIPT , $ stepEvent , $ entry );
60
33
//Set javascript error in MagentoWebDriver internal array
61
34
$ module ->setJsError ("ERROR( {$ entry ["level " ]}) - " . $ entry ["message " ]);
62
35
}
@@ -70,7 +43,7 @@ public function logErrors($module, $stepEvent)
70
43
* @param string $type
71
44
* @return array
72
45
*/
73
- public function getLogsOfType ($ log , $ type )
46
+ public static function getLogsOfType ($ log , $ type )
74
47
{
75
48
$ errors = [];
76
49
foreach ($ log as $ entry ) {
@@ -88,7 +61,7 @@ public function getLogsOfType($log, $type)
88
61
* @param string $type
89
62
* @return array
90
63
*/
91
- public function filterLogsOfType ($ log , $ type )
64
+ public static function filterLogsOfType ($ log , $ type )
92
65
{
93
66
$ errors = [];
94
67
foreach ($ log as $ entry ) {
@@ -106,7 +79,7 @@ public function filterLogsOfType($log, $type)
106
79
* @param array $entry
107
80
* @return void
108
81
*/
109
- private function logError ($ type , $ stepEvent , $ entry )
82
+ private static function logError ($ type , $ stepEvent , $ entry )
110
83
{
111
84
//TODO Add to overall log
112
85
$ stepEvent ->getTest ()->getScenario ()->comment ("{$ type } ERROR( {$ entry ["level " ]}) - " . $ entry ["message " ]);
0 commit comments