77namespace Magento \FunctionalTestingFramework \Extension ;
88
99/**
10- * Class ErrorLogger
10+ * Class BrowserLogUtil
1111 * @package Magento\FunctionalTestingFramework\Extension
1212 */
13- class ErrorLogger
13+ class BrowserLogUtil
1414{
1515 const LOG_TYPE_BROWSER = "browser " ;
1616 const ERROR_TYPE_JAVASCRIPT = "javascript " ;
1717
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-
4518 /**
4619 * Loops through stepEvent for browser log entries
4720 *
4821 * @param \Magento\FunctionalTestingFramework\Module\MagentoWebDriver $module
4922 * @param \Codeception\Event\StepEvent $stepEvent
5023 * @return void
5124 */
52- public function logErrors ($ module , $ stepEvent )
25+ public static function logErrors ($ module , $ stepEvent )
5326 {
5427 //Types available should be "server", "browser", "driver". Only care about browser at the moment.
5528 if (in_array (self ::LOG_TYPE_BROWSER , $ module ->webDriver ->manage ()->getAvailableLogTypes ())) {
5629 $ 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 );
5831 foreach ($ jsErrors as $ entry ) {
59- $ this -> logError (self ::ERROR_TYPE_JAVASCRIPT , $ stepEvent , $ entry );
32+ self :: logError (self ::ERROR_TYPE_JAVASCRIPT , $ stepEvent , $ entry );
6033 //Set javascript error in MagentoWebDriver internal array
6134 $ module ->setJsError ("ERROR( {$ entry ["level " ]}) - " . $ entry ["message " ]);
6235 }
@@ -70,7 +43,7 @@ public function logErrors($module, $stepEvent)
7043 * @param string $type
7144 * @return array
7245 */
73- public function getLogsOfType ($ log , $ type )
46+ public static function getLogsOfType ($ log , $ type )
7447 {
7548 $ errors = [];
7649 foreach ($ log as $ entry ) {
@@ -88,7 +61,7 @@ public function getLogsOfType($log, $type)
8861 * @param string $type
8962 * @return array
9063 */
91- public function filterLogsOfType ($ log , $ type )
64+ public static function filterLogsOfType ($ log , $ type )
9265 {
9366 $ errors = [];
9467 foreach ($ log as $ entry ) {
@@ -106,7 +79,7 @@ public function filterLogsOfType($log, $type)
10679 * @param array $entry
10780 * @return void
10881 */
109- private function logError ($ type , $ stepEvent , $ entry )
82+ private static function logError ($ type , $ stepEvent , $ entry )
11083 {
11184 //TODO Add to overall log
11285 $ stepEvent ->getTest ()->getScenario ()->comment ("{$ type } ERROR( {$ entry ["level " ]}) - " . $ entry ["message " ]);
0 commit comments