@@ -179,7 +179,6 @@ public function testContainToJoinsOneLevel() {
179
179
180
180
$ s = $ query
181
181
->select ('foo.id ' )
182
- ->repository ($ this ->table )
183
182
->contain ($ contains )->sql ();
184
183
}
185
184
@@ -255,10 +254,11 @@ public function testContainToFieldsDefault() {
255
254
256
255
/**
257
256
* Tests that results are grouped correctly when using contain()
257
+ * and results are not hydrated
258
258
*
259
259
* @return void
260
260
**/
261
- public function testContainResultFetchingOneLevel () {
261
+ public function testContainResultFetchingOneLevelNoHydration () {
262
262
$ this ->_createTables ();
263
263
264
264
$ table = Table::build ('article ' , ['table ' => 'articles ' ]);
@@ -268,6 +268,7 @@ public function testContainResultFetchingOneLevel() {
268
268
$ query = new Query ($ this ->connection , $ table );
269
269
$ results = $ query ->select ()
270
270
->contain ('author ' )
271
+ ->hydrate (false )
271
272
->order (['article.id ' => 'asc ' ])
272
273
->toArray ();
273
274
$ expected = [
@@ -318,14 +319,15 @@ public function strategiesProvider() {
318
319
}
319
320
320
321
/**
321
- * Tests that HasMany associations are correctly eager loaded.
322
+ * Tests that HasMany associations are correctly eager loaded and results
323
+ * correctly nested when no hydration is used
322
324
* Also that the query object passes the correct parent model keys to the
323
325
* association objects in order to perform eager loading with select strategy
324
326
*
325
327
* @dataProvider strategiesProvider
326
328
* @return void
327
329
**/
328
- public function testHasManyEagerLoading ($ strategy ) {
330
+ public function testHasManyEagerLoadingNoHydration ($ strategy ) {
329
331
$ this ->_createTables ();
330
332
331
333
$ table = Table::build ('author ' , ['connection ' => $ this ->connection ]);
@@ -337,7 +339,10 @@ public function testHasManyEagerLoading($strategy) {
337
339
]);
338
340
$ query = new Query ($ this ->connection , $ table );
339
341
340
- $ results = $ query ->select ()->contain ('article ' )->toArray ();
342
+ $ results = $ query ->select ()
343
+ ->contain ('article ' )
344
+ ->hydrate (false )
345
+ ->toArray ();
341
346
$ expected = [
342
347
[
343
348
'id ' => 1 ,
@@ -386,6 +391,7 @@ public function testHasManyEagerLoading($strategy) {
386
391
$ results = $ query ->repository ($ table )
387
392
->select ()
388
393
->contain (['article ' => ['conditions ' => ['id ' => 2 ]]])
394
+ ->hydrate (false )
389
395
->toArray ();
390
396
unset($ expected [0 ]['articles ' ]);
391
397
$ this ->assertEquals ($ expected , $ results );
@@ -398,7 +404,7 @@ public function testHasManyEagerLoading($strategy) {
398
404
* @dataProvider strategiesProvider
399
405
* @return void
400
406
**/
401
- public function testHasManyEagerLoadingFieldsAndOrder ($ strategy ) {
407
+ public function testHasManyEagerLoadingFieldsAndOrderNoHydration ($ strategy ) {
402
408
$ this ->_createTables ();
403
409
404
410
$ table = Table::build ('author ' , ['connection ' => $ this ->connection ]);
@@ -413,6 +419,7 @@ public function testHasManyEagerLoadingFieldsAndOrder($strategy) {
413
419
'sort ' => ['id ' => 'DESC ' ]
414
420
]
415
421
])
422
+ ->hydrate (false )
416
423
->toArray ();
417
424
$ expected = [
418
425
[
@@ -448,7 +455,7 @@ public function testHasManyEagerLoadingFieldsAndOrder($strategy) {
448
455
* @dataProvider strategiesProvider
449
456
* @return void
450
457
**/
451
- public function testHasManyEagerLoadingDeep ($ strategy ) {
458
+ public function testHasManyEagerLoadingDeepNoHydration ($ strategy ) {
452
459
$ this ->_createTables ();
453
460
454
461
$ table = Table::build ('author ' , ['connection ' => $ this ->connection ]);
@@ -463,6 +470,7 @@ public function testHasManyEagerLoadingDeep($strategy) {
463
470
464
471
$ results = $ query ->select ()
465
472
->contain (['article ' => ['author ' ]])
473
+ ->hydrate (false )
466
474
->toArray ();
467
475
$ expected = [
468
476
[
@@ -535,6 +543,7 @@ public function testHasManyEagerLoadingFromSecondaryTable($strategy) {
535
543
$ results = $ query ->select ()
536
544
->contain (['author ' => ['post ' ]])
537
545
->order (['article.id ' => 'ASC ' ])
546
+ ->hydrate (false )
538
547
->toArray ();
539
548
$ expected = [
540
549
[
@@ -623,7 +632,7 @@ public function testHasManyEagerLoadingFromSecondaryTable($strategy) {
623
632
* @dataProvider strategiesProvider
624
633
* @return void
625
634
**/
626
- public function testBelongsToManyEagerLoading ($ strategy ) {
635
+ public function testBelongsToManyEagerLoadingNoHydration ($ strategy ) {
627
636
$ this ->_createTables ();
628
637
629
638
$ table = Table::build ('Article ' , ['connection ' => $ this ->connection ]);
@@ -635,7 +644,7 @@ public function testBelongsToManyEagerLoading($strategy) {
635
644
$ table ->belongsToMany ('Tag ' , ['property ' => 'tags ' , 'strategy ' => $ strategy ]);
636
645
$ query = new Query ($ this ->connection , $ table );
637
646
638
- $ results = $ query ->select ()->contain ('Tag ' )->toArray ();
647
+ $ results = $ query ->select ()->contain ('Tag ' )->hydrate ( false )-> toArray ();
639
648
$ expected = [
640
649
[
641
650
'id ' => 1 ,
@@ -687,6 +696,7 @@ public function testBelongsToManyEagerLoading($strategy) {
687
696
688
697
$ results = $ query ->select ()
689
698
->contain (['Tag ' => ['conditions ' => ['id ' => 3 ]]])
699
+ ->hydrate (false )
690
700
->toArray ();
691
701
$ expected = [
692
702
[
@@ -727,7 +737,7 @@ public function testBelongsToManyEagerLoading($strategy) {
727
737
*
728
738
* @return void
729
739
*/
730
- public function testFilteringByHasMany () {
740
+ public function testFilteringByHasManyNoHydration () {
731
741
$ this ->_createTables ();
732
742
733
743
$ query = new Query ($ this ->connection , $ this ->table );
@@ -737,6 +747,7 @@ public function testFilteringByHasMany() {
737
747
738
748
$ results = $ query ->repository ($ table )
739
749
->select ()
750
+ ->hydrate (false )
740
751
->contain (['article ' => [
741
752
'matching ' => true ,
742
753
'conditions ' => ['article.id ' => 2 ]
@@ -765,7 +776,7 @@ public function testFilteringByHasMany() {
765
776
*
766
777
* @return void
767
778
**/
768
- public function testFilteringByBelongsToMany () {
779
+ public function testFilteringByBelongsToManyNoHydration () {
769
780
$ this ->_createTables ();
770
781
771
782
$ query = new Query ($ this ->connection , $ this ->table );
@@ -782,6 +793,7 @@ public function testFilteringByBelongsToMany() {
782
793
'matching ' => true ,
783
794
'conditions ' => ['Tag.id ' => 3 ]
784
795
]])
796
+ ->hydrate (false )
785
797
->toArray ();
786
798
$ expected = [
787
799
[
@@ -804,6 +816,7 @@ public function testFilteringByBelongsToMany() {
804
816
'matching ' => true ,
805
817
'conditions ' => ['Tag.name ' => 'tag2 ' ]]
806
818
])
819
+ ->hydrate (false )
807
820
->toArray ();
808
821
$ expected = [
809
822
[
@@ -1043,7 +1056,7 @@ public function testFirstDirtyQuery() {
1043
1056
$ this ->_createTables ();
1044
1057
$ table = Table::build ('article ' , ['table ' => 'articles ' ]);
1045
1058
$ query = new Query ($ this ->connection , $ table );
1046
- $ result = $ query ->select (['id ' ])->first ();
1059
+ $ result = $ query ->select (['id ' ])->hydrate ( false )-> first ();
1047
1060
$ this ->assertEquals (['id ' => 1 ], $ result );
1048
1061
$ this ->assertEquals (1 , $ query ->clause ('limit ' ));
1049
1062
$ result = $ query ->select (['id ' ])->first ();
@@ -1061,7 +1074,7 @@ public function testFirstCleanQuery() {
1061
1074
$ query = new Query ($ this ->connection , $ table );
1062
1075
$ query ->select (['id ' ])->toArray ();
1063
1076
1064
- $ first = $ query ->first ();
1077
+ $ first = $ query ->hydrate ( false )-> first ();
1065
1078
$ this ->assertEquals (['id ' => 1 ], $ first );
1066
1079
$ this ->assertNull ($ query ->clause ('limit ' ));
1067
1080
}
@@ -1077,7 +1090,7 @@ public function testFirstSameResult() {
1077
1090
$ query = new Query ($ this ->connection , $ table );
1078
1091
$ query ->select (['id ' ])->toArray ();
1079
1092
1080
- $ first = $ query ->first ();
1093
+ $ first = $ query ->hydrate ( false )-> first ();
1081
1094
$ resultSet = $ query ->execute ();
1082
1095
$ this ->assertEquals (['id ' => 1 ], $ first );
1083
1096
$ this ->assertSame ($ resultSet , $ query ->execute ());
@@ -1092,7 +1105,7 @@ public function testHydrateSimple() {
1092
1105
$ this ->_createTables ();
1093
1106
$ table = Table::build ('article ' , ['table ' => 'articles ' ]);
1094
1107
$ query = new Query ($ this ->connection , $ table );
1095
- $ results = $ query ->select ()->hydrate ( true )-> execute ()->toArray ();
1108
+ $ results = $ query ->select ()->execute ()->toArray ();
1096
1109
1097
1110
$ this ->assertCount (3 , $ results );
1098
1111
foreach ($ results as $ r ) {
@@ -1124,7 +1137,6 @@ public function testHydrateWithHasMany() {
1124
1137
$ query = new Query ($ this ->connection , $ table );
1125
1138
$ results = $ query ->select ()
1126
1139
->contain ('article ' )
1127
- ->hydrate (true )
1128
1140
->toArray ();
1129
1141
1130
1142
$ first = $ results [0 ];
@@ -1171,7 +1183,6 @@ public function testHydrateBelongsToMany() {
1171
1183
$ results = $ query
1172
1184
->select ()
1173
1185
->contain ('Tag ' )
1174
- ->hydrate (true )
1175
1186
->toArray ();
1176
1187
1177
1188
$ first = $ results [0 ];
@@ -1211,7 +1222,6 @@ public function testHydrateBelongsTo() {
1211
1222
$ results = $ query ->select ()
1212
1223
->contain ('author ' )
1213
1224
->order (['article.id ' => 'asc ' ])
1214
- ->hydrate (true )
1215
1225
->toArray ();
1216
1226
1217
1227
$ this ->assertCount (3 , $ results );
@@ -1240,7 +1250,6 @@ public function testHydrateDeep() {
1240
1250
1241
1251
$ results = $ query ->select ()
1242
1252
->contain (['article ' => ['author ' ]])
1243
- ->hydrate (true )
1244
1253
->toArray ();
1245
1254
1246
1255
$ this ->assertCount (4 , $ results );
@@ -1264,7 +1273,7 @@ public function testHydrateCustomObject() {
1264
1273
'entityClass ' => '\\' . $ class
1265
1274
]);
1266
1275
$ query = new Query ($ this ->connection , $ table );
1267
- $ results = $ query ->select ()->hydrate ( true )-> execute ()->toArray ();
1276
+ $ results = $ query ->select ()->execute ()->toArray ();
1268
1277
1269
1278
$ this ->assertCount (3 , $ results );
1270
1279
foreach ($ results as $ r ) {
@@ -1305,7 +1314,6 @@ public function testHydrateWithHasManyCustomEntity() {
1305
1314
$ query = new Query ($ this ->connection , $ table );
1306
1315
$ results = $ query ->select ()
1307
1316
->contain ('article ' )
1308
- ->hydrate (true )
1309
1317
->toArray ();
1310
1318
1311
1319
$ first = $ results [0 ];
@@ -1345,7 +1353,6 @@ public function testHydrateBelongsToCustomEntity() {
1345
1353
$ results = $ query ->select ()
1346
1354
->contain ('author ' )
1347
1355
->order (['article.id ' => 'asc ' ])
1348
- ->hydrate (true )
1349
1356
->toArray ();
1350
1357
1351
1358
$ first = $ results [0 ];
0 commit comments