This repository was archived by the owner on Jan 29, 2020. It is now read-only.
File tree 2 files changed +47
-0
lines changed
2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change 16
16
use Zend \Http \Response ;
17
17
use Zend \Mvc \MvcEvent ;
18
18
use Zend \Mvc \Router \RouteMatch ;
19
+ use ZendTest \Mvc \Controller \TestAsset \RestfulContentTypeTestController ;
19
20
20
21
class RestfulControllerTest extends TestCase
21
22
{
@@ -76,6 +77,22 @@ public function testDispatchInvokesCreateMethodWhenNoActionPresentAndPostInvoked
76
77
$ this ->assertEquals ('create ' , $ this ->routeMatch ->getParam ('action ' ));
77
78
}
78
79
80
+ public function testCanReceiveStringAsRequestContent ()
81
+ {
82
+ $ string = "any content " ;
83
+ $ this ->request ->setMethod ('PUT ' );
84
+ $ this ->request ->setContent ($ string );
85
+ $ this ->routeMatch ->setParam ('id ' , $ id = 1 );
86
+
87
+ $ controller = new RestfulContentTypeTestController ();
88
+ $ controller ->setEvent ($ this ->event );
89
+ $ result = $ controller ->dispatch ($ this ->request , $ this ->response );
90
+
91
+ $ this ->assertEquals ($ id , $ result ['id ' ]);
92
+ $ this ->assertEquals ($ string , $ result ['data ' ]);
93
+ $ this ->assertEquals ('update ' , $ this ->routeMatch ->getParam ('action ' ));
94
+ }
95
+
79
96
public function testDispatchInvokesUpdateMethodWhenNoActionPresentAndPutInvokedWithIdentifier ()
80
97
{
81
98
$ entity = ['name ' => __FUNCTION__ ];
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Zend Framework (http://framework.zend.com/)
4
+ *
5
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
6
+ * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7
+ * @license http://framework.zend.com/license/new-bsd New BSD License
8
+ */
9
+
10
+ namespace ZendTest \Mvc \Controller \TestAsset ;
11
+
12
+ use Zend \Mvc \Controller \AbstractRestfulController ;
13
+
14
+ class RestfulContentTypeTestController extends AbstractRestfulController
15
+ {
16
+ /**
17
+ * Update an existing resource
18
+ *
19
+ * @param mixed $id
20
+ * @param mixed $data
21
+ * @return array
22
+ */
23
+ public function update ($ id , $ data )
24
+ {
25
+ return [
26
+ 'id ' => $ id ,
27
+ 'data ' => $ data
28
+ ];
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments