@@ -497,6 +497,49 @@ public function testNewInstance()
497
497
$ this ->assertTrue (isset ($ a ->persistence ));
498
498
}
499
499
500
+ public function testDuplicate1 ()
501
+ {
502
+ $ this ->setDb ([
503
+ 'rate ' => [
504
+ ['dat ' => '18/12/12 ' , 'bid ' => 3.4 , 'ask ' => 9.4 ],
505
+ ['dat ' => '12/12/12 ' , 'bid ' => 8.3 , 'ask ' => 9.2 ],
506
+ ],
507
+ ]);
508
+
509
+ $ db = new Persistence \Sql ($ this ->db ->connection );
510
+ $ m = new Model_Rate ($ db );
511
+
512
+ $ m ->load (1 )->duplicate ()->save ();
513
+
514
+ $ this ->assertSame ([
515
+ ['dat ' => '18/12/12 ' ],
516
+ ['dat ' => '12/12/12 ' ],
517
+ ['dat ' => '18/12/12 ' ],
518
+ ], $ m ->export (['dat ' ]));
519
+ }
520
+
521
+ public function testDuplicate2 ()
522
+ {
523
+ $ this ->setDb ([
524
+ 'rate ' => [
525
+ ['dat ' => '18/12/12 ' , 'bid ' => 3.4 , 'ask ' => 9.4 ],
526
+ ['dat ' => '12/12/12 ' , 'bid ' => 8.3 , 'ask ' => 9.2 ],
527
+ ],
528
+ ]);
529
+
530
+ $ db = new Persistence \Sql ($ this ->db ->connection );
531
+ $ m = new Model_Rate ($ db );
532
+
533
+ $ m ->load (1 )->duplicate (2 )->save ();
534
+
535
+ $ this ->assertSame (2 , $ m ->getId ());
536
+
537
+ $ this ->assertSame ([
538
+ ['id ' => '1 ' , 'dat ' => '18/12/12 ' , 'bid ' => '3.4 ' , 'ask ' => '9.4 ' ],
539
+ ['id ' => '2 ' , 'dat ' => '18/12/12 ' , 'bid ' => '3.4 ' , 'ask ' => '9.4 ' ],
540
+ ], $ m ->export ());
541
+ }
542
+
500
543
public function testTableNameDots ()
501
544
{
502
545
$ d = new Model ($ this ->db , 'db2.doc ' );
0 commit comments