1010namespace utest \orm \func \object \property ;
1111
1212use umi \orm \collection \ICollectionFactory ;
13+ use umi \orm \object \property \calculable \ICalculableProperty ;
1314use utest \orm \ORMDbTestCase ;
1415
1516/**
@@ -49,7 +50,7 @@ protected function getCollectionConfig()
4950 ];
5051 }
5152
52- public function testObject ()
53+ public function testNewObject ()
5354 {
5455 $ userCollection = $ this ->getCollectionManager ()->getCollection (self ::USERS_USER );
5556
@@ -71,4 +72,44 @@ public function testObject()
7172 );
7273
7374 }
75+
76+ public function testModifiedObject ()
77+ {
78+ $ userCollection = $ this ->getCollectionManager ()->getCollection (self ::USERS_USER );
79+
80+ $ user = $ userCollection ->add ('supervisor ' );
81+ $ user ->setValue ('firstName ' , 'Name ' );
82+ $ user ->setValue ('lastName ' , 'LastName ' );
83+
84+ $ this ->getObjectPersister ()->commit ();
85+
86+ $ this ->assertEquals (2 , $ user ->getVersion ());
87+
88+ $ user ->setValue ('firstName ' , 'New name ' );
89+ $ this ->getObjectPersister ()->commit ();
90+ $ this ->assertEquals (3 , $ user ->getVersion ());
91+
92+ $ this ->assertEquals (
93+ 'Name LastName ' ,
94+ $ user ->getValue ('fullName ' ),
95+ 'Ожидается, что значение для полного имени не было пересчитано '
96+ );
97+
98+ /**
99+ * @var ICalculableProperty $fullNameProperty
100+ */
101+ $ fullNameProperty = $ user ->getProperty ('fullName ' );
102+ $ fullNameProperty ->recalculate ();
103+ $ this ->getObjectPersister ()->commit ();
104+
105+ $ this ->assertEquals (4 , $ user ->getVersion ());
106+
107+ $ this ->assertEquals (
108+ 'New name LastName ' ,
109+ $ user ->getValue ('fullName ' ),
110+ 'Ожидается, что значение для полного имени было пересчитано '
111+ );
112+
113+
114+ }
74115}
0 commit comments