This repository was archived by the owner on Jan 29, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change 1616use Zend \Http \Response ;
1717use Zend \Mvc \MvcEvent ;
1818use Zend \Mvc \Router \RouteMatch ;
19+ use ZendTest \Mvc \Controller \TestAsset \RestfulContentTypeTestController ;
1920
2021class RestfulControllerTest extends TestCase
2122{
@@ -76,6 +77,22 @@ public function testDispatchInvokesCreateMethodWhenNoActionPresentAndPostInvoked
7677 $ this ->assertEquals ('create ' , $ this ->routeMatch ->getParam ('action ' ));
7778 }
7879
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+
7996 public function testDispatchInvokesUpdateMethodWhenNoActionPresentAndPutInvokedWithIdentifier ()
8097 {
8198 $ 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