@@ -547,100 +547,102 @@ public function testHstore()
547
547
{
548
548
$ this ->create ();
549
549
550
- $ properties = array (
551
- 'age ' => '23 ' ,
552
- 'weight ' => 80 ,
553
- 'comment ' => null ,
554
- );
555
-
556
- $ user =
557
- TestUser::create ()->
558
- setCity (
559
- $ moscow = TestCity::create ()->
560
- setName ('Moscow ' )
561
- )->
562
- setCredentials (
563
- Credentials::create ()->
564
- setNickname ('fake ' )->
565
- setPassword (sha1 ('passwd ' ))
566
- )->
567
- setLastLogin (
568
- Timestamp::create (time ())
569
- )->
570
- setRegistered (
571
- Timestamp::create (time ())->modify ('-1 day ' )
572
- )->
573
- setProperties (Hstore::make ($ properties ));
574
-
575
- $ moscow = TestCity::dao ()->add ($ moscow );
576
-
577
- $ user = TestUser::dao ()->add ($ user );
578
-
579
- Cache::me ()->clean ();
580
- TestUser::dao ()->dropIdentityMap ();
581
-
582
- $ user = TestUser::dao ()->getById ('1 ' );
583
-
584
- $ this ->assertInstanceOf ('Hstore ' , $ user ->getProperties ());
585
-
586
- $ this ->assertEquals (
587
- $ properties ,
588
- $ user ->getProperties ()->getList ()
589
- );
590
-
591
-
592
- $ form = TestUser::proto ()->makeForm ();
593
-
594
- $ form ->get ('properties ' )->
595
- setFormMapping (
596
- array (
597
- Primitive::string ('age ' ),
598
- Primitive::integer ('weight ' ),
599
- Primitive::string ('comment ' ),
600
- )
550
+ foreach (DBTestPool::me ()->getPool () as $ connector => $ db ) {
551
+ DBPool::me ()->setDefault ($ db );
552
+ $ properties = array (
553
+ 'age ' => '23 ' ,
554
+ 'weight ' => 80 ,
555
+ 'comment ' => null ,
601
556
);
602
-
603
- $ form ->import (
604
- array ('id ' => $ user ->getId ())
605
- );
606
-
607
- $ this ->assertNotNull ($ form ->getValue ('id ' ));
608
-
609
- $ object = $ user ;
610
-
611
- FormUtils::object2form ($ object , $ form );
612
-
613
- $ this ->assertInstanceOf ('Hstore ' , $ form ->getValue ('properties ' ));
614
-
615
- $ this ->assertEquals (
616
- array_filter ($ properties ),
617
- $ form ->getValue ('properties ' )->getList ()
618
- );
619
-
620
- $ subform = $ form ->get ('properties ' )->getInnerForm ();
621
-
622
- $ this ->assertEquals (
623
- $ subform ->getValue ('age ' ),
624
- '23 '
625
- );
626
-
627
- $ this ->assertEquals (
628
- $ subform ->getValue ('weight ' ),
629
- 80
630
- );
631
-
632
- $ this ->assertNull (
633
- $ subform ->getValue ('comment ' )
634
- );
635
-
636
- $ user = new TestUser ();
637
-
638
- FormUtils::form2object ($ form , $ user , false );
639
-
640
- $ this ->assertEquals (
641
- $ user ->getProperties ()->getList (),
642
- array_filter ($ properties )
643
- );
557
+
558
+ $ user =
559
+ TestUser::create ()->
560
+ setCity (
561
+ $ moscow = TestCity::create ()->
562
+ setName ('Moscow ' )
563
+ )->
564
+ setCredentials (
565
+ Credentials::create ()->
566
+ setNickname ('fake ' )->
567
+ setPassword (sha1 ('passwd ' ))
568
+ )->
569
+ setLastLogin (
570
+ Timestamp::create (time ())
571
+ )->
572
+ setRegistered (
573
+ Timestamp::create (time ())->modify ('-1 day ' )
574
+ )->
575
+ setProperties (Hstore::make ($ properties ));
576
+
577
+ $ moscow = TestCity::dao ()->add ($ moscow );
578
+
579
+ $ user = TestUser::dao ()->add ($ user );
580
+
581
+ Cache::me ()->clean ();
582
+ TestUser::dao ()->dropIdentityMap ();
583
+
584
+ $ user = TestUser::dao ()->getById ('1 ' );
585
+
586
+ $ this ->assertInstanceOf ('Hstore ' , $ user ->getProperties ());
587
+
588
+ $ this ->assertEquals (
589
+ $ properties ,
590
+ $ user ->getProperties ()->getList ()
591
+ );
592
+
593
+ $ form = TestUser::proto ()->makeForm ();
594
+
595
+ $ form ->get ('properties ' )->
596
+ setFormMapping (
597
+ array (
598
+ Primitive::string ('age ' ),
599
+ Primitive::integer ('weight ' ),
600
+ Primitive::string ('comment ' ),
601
+ )
602
+ );
603
+
604
+ $ form ->import (
605
+ array ('id ' => $ user ->getId ())
606
+ );
607
+
608
+ $ this ->assertNotNull ($ form ->getValue ('id ' ));
609
+
610
+ $ object = $ user ;
611
+
612
+ FormUtils::object2form ($ object , $ form );
613
+
614
+ $ this ->assertInstanceOf ('Hstore ' , $ form ->getValue ('properties ' ));
615
+
616
+ $ this ->assertEquals (
617
+ array_filter ($ properties ),
618
+ $ form ->getValue ('properties ' )->getList ()
619
+ );
620
+
621
+ $ subform = $ form ->get ('properties ' )->getInnerForm ();
622
+
623
+ $ this ->assertEquals (
624
+ $ subform ->getValue ('age ' ),
625
+ '23 '
626
+ );
627
+
628
+ $ this ->assertEquals (
629
+ $ subform ->getValue ('weight ' ),
630
+ 80
631
+ );
632
+
633
+ $ this ->assertNull (
634
+ $ subform ->getValue ('comment ' )
635
+ );
636
+
637
+ $ user = new TestUser ();
638
+
639
+ FormUtils::form2object ($ form , $ user , false );
640
+
641
+ $ this ->assertEquals (
642
+ $ user ->getProperties ()->getList (),
643
+ array_filter ($ properties )
644
+ );
645
+ }
644
646
645
647
$ this ->drop ();
646
648
}
0 commit comments