@@ -721,16 +721,10 @@ public function testBelongsToManyWithMixedData()
721
721
]
722
722
];
723
723
724
- $ articles = TableRegistry::get ('Articles ' );
725
- $ articles ->belongsToMany ('Tags ' );
726
-
727
724
$ tags = TableRegistry::get ('Tags ' );
728
725
729
- $ article = $ articles ->newEntity ($ data , [
730
- 'associated ' => [
731
- 'Tags '
732
- ]
733
- ]);
726
+ $ marshaller = new Marshaller ($ this ->articles );
727
+ $ article = $ marshaller ->one ($ data , ['associated ' => ['Tags ' ]]);
734
728
735
729
$ this ->assertEquals ($ data ['tags ' ][0 ]['name ' ], $ article ->tags [0 ]->name );
736
730
$ this ->assertEquals ($ data ['tags ' ][1 ]['name ' ], $ article ->tags [1 ]->name );
@@ -741,7 +735,7 @@ public function testBelongsToManyWithMixedData()
741
735
$ this ->assertEquals ($ article ->tags [2 ]->isNew (), false );
742
736
743
737
$ tagCount = $ tags ->find ()->count ();
744
- $ articles ->save ($ article );
738
+ $ this -> articles ->save ($ article );
745
739
746
740
$ this ->assertEquals ($ tagCount + 2 , $ tags ->find ()->count ());
747
741
}
@@ -754,20 +748,18 @@ public function testBelongsToManyWithMixedData()
754
748
public function testHasManyWithIds ()
755
749
{
756
750
$ data = [
757
- 'username ' => 'lux ' ,
758
- 'password ' => 'passphrase ' ,
751
+ 'title ' => 'article ' ,
752
+ 'body ' => 'some content ' ,
759
753
'comments ' => [
760
754
'_ids ' => [1 , 2 ]
761
755
]
762
756
];
763
757
764
- $ userTable = TableRegistry::get ('Users ' );
765
- $ userTable ->hasMany ('Comments ' );
766
- $ commentTable = TableRegistry::get ('Comments ' );
767
- $ user = $ userTable ->newEntity ($ data , ['associated ' => ['Comments ' ]]);
758
+ $ marshaller = new Marshaller ($ this ->articles );
759
+ $ article = $ marshaller ->one ($ data , ['associated ' => ['Comments ' ]]);
768
760
769
- $ this ->assertEquals ($ user ->comments [0 ], $ commentTable ->get (1 ));
770
- $ this ->assertEquals ($ user ->comments [1 ], $ commentTable ->get (2 ));
761
+ $ this ->assertEquals ($ article ->comments [0 ], $ this -> comments ->get (1 ));
762
+ $ this ->assertEquals ($ article ->comments [1 ], $ this -> comments ->get (2 ));
771
763
}
772
764
773
765
/**
@@ -785,11 +777,12 @@ public function testHasManyInvalidData()
785
777
]
786
778
];
787
779
788
- $ article = $ this ->articles ->newEntity ($ data , ['associated ' => ['Comments ' ]]);
780
+ $ marshaller = new Marshaller ($ this ->articles );
781
+ $ article = $ marshaller ->one ($ data , ['associated ' => ['Comments ' ]]);
789
782
$ this ->assertEmpty ($ article ->comments );
790
783
791
784
$ data ['comments ' ] = 1 ;
792
- $ article = $ this -> articles -> newEntity ($ data , ['associated ' => ['Comments ' ]]);
785
+ $ article = $ marshaller -> one ($ data , ['associated ' => ['Comments ' ]]);
793
786
$ this ->assertEmpty ($ article ->comments );
794
787
}
795
788
0 commit comments