When I run PHPUnit locally against MediaWiki core only, it hangs for 5 minutes while tearing down UploadFromUrlTest::testSyncDownload. During that time, memory usage increases by about 3GB.
The test is unusual in that it returns an array. This causes TestCase::shouldInvocationMockerBeReset() to call Enumerator::enumerate() on the return value, which is where I find it when I capture a stack trace with gdb.
The array has a FauxRequest with a Session, which then links to SessionBackend then HookRunner, ObjectFactory and the whole kitchen sink.
Enumerator::enumerate() uses a loop of array_merge() and so probably has O(N^2) time order.