File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -111,8 +111,10 @@ public function toArray()
111111 'presentation ' => [
112112 'documentTarget ' => $ this ->target ,
113113 ],
114- 'custom ' => $ this ->custom_params ,
115114 ];
115+ if (!empty ($ this ->custom_params )) {
116+ $ resource ['custom ' ] = $ this ->custom_params ;
117+ }
116118 if ($ this ->lineitem !== null ) {
117119 $ resource ['lineItem ' ] = [
118120 'scoreMaximum ' => $ this ->lineitem ->getScoreMaximum (),
Original file line number Diff line number Diff line change @@ -147,17 +147,16 @@ public function testItCastsToArray()
147147 'presentation ' => [
148148 'documentTarget ' => 'iframe ' ,
149149 ],
150- 'custom ' => [],
151150 'lineItem ' => [
152151 'scoreMaximum ' => 80 ,
153152 'label ' => 'lineitem_label ' ,
154153 ],
155154 ];
156155 $ lineitem = Mockery::mock (LtiLineitem::class);
157156 $ lineitem ->shouldReceive ('getScoreMaximum ' )
158- ->once ()->andReturn ($ expected ['lineItem ' ]['scoreMaximum ' ]);
157+ ->twice ()->andReturn ($ expected ['lineItem ' ]['scoreMaximum ' ]);
159158 $ lineitem ->shouldReceive ('getLabel ' )
160- ->once ()->andReturn ($ expected ['lineItem ' ]['label ' ]);
159+ ->twice ()->andReturn ($ expected ['lineItem ' ]['label ' ]);
161160
162161 $ this ->deepLinkResource ->setTitle ($ expected ['title ' ]);
163162 $ this ->deepLinkResource ->setText ($ expected ['text ' ]);
@@ -167,5 +166,11 @@ public function testItCastsToArray()
167166 $ result = $ this ->deepLinkResource ->toArray ();
168167
169168 $ this ->assertEquals ($ expected , $ result );
169+
170+ // Test again with custom params
171+ $ expected ['custom ' ] = ['a_key ' => 'a_value ' ];
172+ $ this ->deepLinkResource ->setCustomParams (['a_key ' => 'a_value ' ]);
173+ $ result = $ this ->deepLinkResource ->toArray ();
174+ $ this ->assertEquals ($ expected , $ result );
170175 }
171176}
You can’t perform that action at this time.
0 commit comments