File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ public static function undefined()
2525 public static function assign ($ obj , array $ vars , array $ requiredKeys = [])
2626 {
2727 foreach ($ requiredKeys as $ key ) {
28- if (!isset ($ key , $ vars )) {
28+ if (!isset ($ vars[ $ key ] )) {
2929 throw new InvalidArgumentException ("Key {$ key } is expected to be set and not to be null " );
3030 }
3131 }
Original file line number Diff line number Diff line change 1+ <?php
2+ namespace GraphQL \Tests ;
3+
4+ use GraphQL \Utils ;
5+
6+ class UtilsTest extends \PHPUnit_Framework_TestCase
7+ {
8+ public function testAssignThrowsExceptionOnMissingRequiredKey ()
9+ {
10+ $ object = new \stdClass ();
11+ $ object ->requiredKey = 'value ' ;
12+
13+ try {
14+ Utils::assign ($ object , [], ['requiredKey ' ]);
15+ $ this ->fail ('Expected exception not thrown ' );
16+ } catch (\InvalidArgumentException $ e ) {
17+ $ this ->assertEquals (
18+ "Key requiredKey is expected to be set and not to be null " ,
19+ $ e ->getMessage ());
20+ }
21+ }
22+ }
You can’t perform that action at this time.
0 commit comments