In https://github.com/matomo-org/matomo/blob/4.x-dev/core/Plugin/ReportsProvider.php#L203 the categoryList remain same when running test cases and which leads to use of wrong category info for subsequent testcases.
Ideally the category should be fetched again if idSite is different
It fetches the data only once and uses the same data for subsequent call.
Since this is most likely to affect test cases, we can create a method to unset the variable and call the method from respective test cases
Test cases output started to differ in PHP8 and after debugging came to know that this is a bug when running testcases.