zeroOrMoreTimes()->andReturnFirstArg(); Functions\expect( 'wp_debug_backtrace_summary' )->zeroOrMoreTimes()->andReturn( [] ); $stopwatch = new Stopwatch(); $url = 'https://example.com/'; $collector = new Http_Record_Collector( $stopwatch ); $this->assertTrue( has_action( 'pre_http_request', [ $collector, 'pre_http_request' ] ) ); $this->assertTrue( has_action( 'http_api_debug', [ $collector, 'http_api_debug' ] ) ); $collector->pre_http_request( false, [], $url ); $this->assertTrue( $stopwatch->isStarted( $url ) ); $collector->http_api_debug( [], '', new \stdClass(), [], $url ); $this->assertFalse( $stopwatch->isStarted( $url ) ); } }