11# frozen_string_literal: false
2- require 'test/unit'
2+
3+ require_relative 'helper'
4+
35require 'xmlrpc/client'
46require 'net/http'
57begin
911
1012module XMLRPC
1113 class ClientTest < Test ::Unit ::TestCase
14+ include TestHelper
15+
1216 module Fake
1317 class HTTP < Net ::HTTP
1418 class << self
@@ -217,7 +221,7 @@ def test_request
217221 '/foo' => [ Fake ::Response . new ( fh , [ [ 'Content-Type' , 'text/xml' ] ] ) ]
218222 }
219223
220- client = fake_client ( responses ) . new2 'http://example.org/foo'
224+ client = fake_client ( responses , 'http://example.org/foo' )
221225
222226 resp = client . call ( 'wp.getUsersBlogs' , 'tlo' , 'omg' )
223227
@@ -239,7 +243,7 @@ def test_async_request
239243 '/foo' => [ Fake ::Response . new ( fh , [ [ 'Content-Type' , 'text/xml' ] ] ) ]
240244 }
241245
242- client = fake_client ( responses ) . new2 'http://example.org/foo'
246+ client = fake_client ( responses , 'http://example.org/foo' )
243247
244248 resp = client . call_async ( 'wp.getUsersBlogs' , 'tlo' , 'omg' )
245249
@@ -261,7 +265,7 @@ def test_application_xml_content_type
261265 '/foo' => [ Fake ::Response . new ( fh , [ [ 'Content-Type' , 'application/xml' ] ] ) ]
262266 }
263267
264- client = fake_client ( responses ) . new2 'http://example.org/foo'
268+ client = fake_client ( responses , 'http://example.org/foo' )
265269
266270 resp = client . call ( 'wp.getUsersBlogs' , 'tlo' , 'omg' )
267271
@@ -284,7 +288,7 @@ def test_bad_content_type
284288 '/foo' => [ Fake ::Response . new ( fh ) ]
285289 }
286290
287- client = fake_client ( responses ) . new2 'http://example.org/foo'
291+ client = fake_client ( responses , 'http://example.org/foo' )
288292
289293 resp = client . call ( 'wp.getUsersBlogs' , 'tlo' , 'omg' )
290294
@@ -304,7 +308,7 @@ def test_no_data
304308 '/foo' => [ Fake ::Response . new ( nil , [ [ 'Content-Type' , 'text/xml' ] ] ) ]
305309 }
306310
307- client = fake_client ( responses ) . new2 'http://example.org/foo'
311+ client = fake_client ( responses , 'http://example.org/foo' )
308312
309313 assert_raise ( RuntimeError . new ( "No data" ) ) do
310314 client . call ( 'wp.getUsersBlogs' , 'tlo' , 'omg' )
@@ -318,7 +322,7 @@ def test_i8_tag
318322 '/foo' => [ Fake ::Response . new ( fh ) ]
319323 }
320324
321- client = fake_client ( responses ) . new2 'http://example.org/foo'
325+ client = fake_client ( responses , 'http://example.org/foo' )
322326
323327 resp = client . call ( 'wp.getUsersBlogs' , 'tlo' , 'omg' )
324328
@@ -348,10 +352,13 @@ def read filename
348352 File . read File . expand_path ( File . join ( __FILE__ , '..' , 'data' , filename ) )
349353 end
350354
351- def fake_client responses
352- Class . new ( Fake ::Client ) {
355+ def fake_client ( responses , uri )
356+ client_class = Class . new ( Fake ::Client ) {
353357 define_method ( :net_http ) { |*_ | Fake ::HTTP . new ( responses ) }
354358 }
359+ client = client_class . new2 ( uri )
360+ client . set_parser ( parser )
361+ client
355362 end
356363 end
357364end
0 commit comments