@@ -658,36 +658,38 @@ public function testLimit()
658658 $ this ->assertEquals (4 , $ items ->count ());
659659 }
660660
661- public function testRemoveUpdateExpressionOnQuery ()
661+ public function testRemoveAttributeOnQuery ()
662662 {
663- $ seed = $ this ->seed (['id ' => ['S ' => 'foo ' ]]);
663+ $ this ->seed (['id ' => ['S ' => 'foo ' ]]);
664664
665- $ this ->assertNotNull (array_get ($ seed , 'name.S ' ));
666- $ this ->assertNotNull (array_get ($ seed , 'description.S ' ));
667-
668- $ this ->testModel ->where ('id ' , 'foo ' )->removeAttribute ('description ' , 'name ' );
665+ $ this ->testModel
666+ ->where ('id ' , 'foo ' )
667+ ->removeAttribute ('description ' , 'name ' , 'nested.foo ' , 'nested.nestedArray[0] ' , 'nestedArray[0] ' );
669668
670669 $ item = $ this ->testModel ->find ('foo ' );
671-
672- $ this ->assertNull ($ item ->name );
673- $ this ->assertNull ($ item ->description );
674- $ this ->assertNotNull ($ item ->count );
675- $ this ->assertNotNull ($ item ->author );
670+ $ this ->assertRemoveAttribute ($ item );
676671 }
677672
678- public function testRemoveUpdateExpressionOnModel ()
673+ public function testRemoveAttributeOnModel ()
679674 {
680- $ seed = $ this ->seed (['id ' => ['S ' => 'foo ' ]]);
681-
682- $ this ->assertNotNull (array_get ($ seed , 'name.S ' ));
683- $ this ->assertNotNull (array_get ($ seed , 'description.S ' ));
675+ $ this ->seed (['id ' => ['S ' => 'foo ' ]]);
684676
685677 $ item = $ this ->testModel ->first ();
686- $ item ->removeAttribute ('description ' , 'name ' );
678+ $ item ->removeAttribute ('description ' , 'name ' , ' nested.foo ' , ' nested.nestedArray[0] ' , ' nestedArray[0] ' );
687679 $ item = $ this ->testModel ->first ();
688680
681+ $ this ->assertRemoveAttribute ($ item );
682+ }
683+
684+ protected function assertRemoveAttribute ($ item )
685+ {
689686 $ this ->assertNull ($ item ->name );
690687 $ this ->assertNull ($ item ->description );
688+ $ this ->assertArrayNotHasKey ('foo ' , $ item ->nested );
689+ $ this ->assertCount (0 , $ item ->nested ['nestedArray ' ]);
690+ $ this ->assertCount (1 , $ item ->nestedArray );
691+ $ this ->assertNotContains ('first ' , $ item ->nestedArray );
692+ $ this ->assertNotNull ($ item ->nested ['hello ' ]);
691693 $ this ->assertNotNull ($ item ->count );
692694 $ this ->assertNotNull ($ item ->author );
693695 }
@@ -700,6 +702,19 @@ protected function seed($attributes = [], $exclude = [])
700702 'description ' => ['S ' => str_random (256 )],
701703 'count ' => ['N ' => rand ()],
702704 'author ' => ['S ' => str_random ()],
705+ 'nested ' => [
706+ 'M ' => [
707+ 'foo ' => ['S ' => 'bar ' ],
708+ 'nestedArray ' => ['L ' => [['S ' => 'first ' ]]],
709+ 'hello ' => ['S ' => 'world ' ],
710+ ],
711+ ],
712+ 'nestedArray ' => [
713+ 'L ' => [
714+ ['S ' => 'first ' ],
715+ ['S ' => 'second ' ],
716+ ],
717+ ],
703718 ];
704719
705720 $ item = array_merge ($ item , $ attributes );
0 commit comments