@@ -26,11 +26,18 @@ protected function setUp()
26
26
)->disableOriginalConstructor ()->getMock ();
27
27
28
28
$ renders = [
29
- 'default ' => ['type ' => '*/* ' , 'model ' => \Magento \Framework \Webapi \Rest \Response \Renderer \Json::class],
29
+ 'application_xml ' => [
30
+ 'type ' => 'application/xml ' ,
31
+ 'model ' => \Magento \Framework \Webapi \Rest \Response \Renderer \Xml::class,
32
+ ],
30
33
'application_json ' => [
31
34
'type ' => 'application/json ' ,
32
35
'model ' => \Magento \Framework \Webapi \Rest \Response \Renderer \Json::class,
33
36
],
37
+ 'default ' => [
38
+ 'type ' => '*/* ' ,
39
+ 'model ' => \Magento \Framework \Webapi \Rest \Response \Renderer \Json::class
40
+ ],
34
41
];
35
42
36
43
$ this ->_factory = new \Magento \Framework \Webapi \Rest \Response \RendererFactory (
@@ -42,29 +49,43 @@ protected function setUp()
42
49
43
50
/**
44
51
* Test GET method.
52
+ *
53
+ * @param array $acceptTypes
54
+ * @param string $model
55
+ * @dataProvider getTestDataProvider
45
56
*/
46
- public function testGet ()
57
+ public function testGet ($ acceptTypes , $ model )
47
58
{
48
- $ acceptTypes = ['application/json ' ];
49
-
50
59
/** Mock request getAcceptTypes method to return specified value. */
51
60
$ this ->_requestMock ->expects ($ this ->once ())->method ('getAcceptTypes ' )->will ($ this ->returnValue ($ acceptTypes ));
52
61
/** Mock renderer. */
53
- $ rendererMock = $ this ->getMockBuilder (
54
- \Magento \Framework \Webapi \Rest \Response \Renderer \Json::class
55
- )->disableOriginalConstructor ()->getMock ();
62
+ $ rendererMock = $ this ->getMockBuilder ($ model )->disableOriginalConstructor ()->getMock ();
56
63
/** Mock object to return mocked renderer. */
57
64
$ this ->_objectManagerMock ->expects (
58
65
$ this ->once ()
59
66
)->method (
60
67
'get '
61
68
)->with (
62
- \ Magento \ Framework \ Webapi \ Rest \ Response \ Renderer \Json::class
69
+ $ model
63
70
)->will (
64
71
$ this ->returnValue ($ rendererMock )
65
72
);
66
73
$ this ->_factory ->get ();
67
74
}
75
+
76
+ /**
77
+ * Data provider for method testGet
78
+ *
79
+ * @return array
80
+ */
81
+ public function getTestDataProvider ()
82
+ {
83
+ return [
84
+ [['*/* ' ], \Magento \Framework \Webapi \Rest \Response \Renderer \Json::class],
85
+ [['application/json ' ], \Magento \Framework \Webapi \Rest \Response \Renderer \Json::class],
86
+ [['application/xml ' ], \Magento \Framework \Webapi \Rest \Response \Renderer \Xml::class],
87
+ ];
88
+ }
68
89
69
90
/**
70
91
* Test GET method with wrong Accept HTTP Header.
0 commit comments