magento / magento/magento2-functional-testing-framework

Invalid argument supplied for foreach() at ../src/Magento/FunctionalTestingFramework/Extension/BrowserLogUtil

Open
#893 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
154
Forks
134
PR merge metrics
No merged PRs in 30d

Description

Preconditions
  1. M2.4.3-p1 CE
  2. PHP7.4
Steps to reproduce
  1. After done all config following this guide https://devdocs.magento.com/mftf/docs/getting-started.html#set-up-a-standalone-mftf. I Ran bin/mftf run:test AdminLoginSuccessfulTest and getting an exception [PHPUnit\Framework\Exception] Invalid argument supplied for foreach() at ../src/Magento/FunctionalTestingFramework/Extension/BrowserLogUtil.php:46
    Line 46:
43    public static function getLogsOfType($log, $type)
44    {
45        $errors = [];
46        foreach ($log as $entry) {
47            if (array_key_exists("source", $entry) && $entry["source"] === $type) {
48                $errors[] = $entry;
49            }
50        }
51        return $errors;
52    }

Variable $log at line 46 is string "/session//log".
How do I resolve this issue?

Expected result
  1. bin/mftf run:test AdminLoginSuccessfulTest without exception
Actual result
  1. Please take a look at this https://imgur.com/IKK0Apj
  2. Logs
Test  tests/functional/tests/MFTF/_generated/default/AdminLoginSuccessfulTestCest.php:AdminLoginSuccessfulTest
                                                                                                                                                      
  [PHPUnit\Framework\Exception] Invalid argument supplied for foreach() at ../src/Magento/FunctionalTestingFramework/Extension/BrowserLogUtil.php:46  
                                                                                                                                                      

Scenario Steps:

 1. // Entering Action Group [loginAsAdmin] AdminLoginActionGroup

#1  /home/magento/public_html/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Extension/BrowserLogUtil.php:46
#2  /home/magento/public_html/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Extension/BrowserLogUtil.php:28
#3  /home/magento/public_html/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Extension/TestContextExtension.php:218
#4  /home/magento/public_html/magento2-functional-testing-framework/vendor/symfony/event-dispatcher/EventDispatcher.php:264
#5  /home/magento/public_html/magento2-functional-testing-framework/vendor/symfony/event-dispatcher/EventDispatcher.php:239
#6  /home/magento/public_html/magento2-functional-testing-framework/vendor/symfony/event-dispatcher/EventDispatcher.php:73
#7  /home/magento/public_html/magento2-functional-testing-framework/dev/tests/functional/tests/MFTF/_generated/default/AdminLoginSuccessfulTestCest.php:50
#8  Magento\AcceptanceTest\_default\Backend\AdminLoginSuccessfulTestCest->AdminLoginSuccessfulTest

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/Magento/FunctionalTestingFramework/Extension/BrowserLogUtil.php:46 and trace the call from TestContextExtension.php:218. Reproduce with bin/mftf run:test AdminLoginSuccessfulTest on the stated Magento and PHP versions; done means the test runs without the Invalid argument supplied for foreach() exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.