@@ -36,6 +36,7 @@ public function test_Query()
3636 $ this ->assertEquals ($ result ->getTotalCount (), 3 , 'Checking the total record number. ' );
3737 $ this ->assertEquals ($ result ->getFoundCount (), 3 , 'Checking the found record number. ' );
3838 $ this ->assertEquals ($ result ->getReturnedCount (), 3 , 'Checking the returned record number. ' );
39+ $ this ->assertEquals ($ result ->getPortalNames (), ['Contact ' , 'History ' ], 'The query result returns portal names. ' );
3940
4041 $ counter = 0 ;
4142 foreach ($ result as $ record ) {
@@ -44,6 +45,9 @@ public function test_Query()
4445 $ this ->assertEquals ($ record ->id , 1 , 'Field value has to match with defined value. ' );
4546 $ this ->assertEquals ($ record ->name , 'Masayuki Nii ' , 'Field value has to match with defined value. ' );
4647 $ this ->assertEquals ($ record ->mail , 'msyk@msyk.net ' , 'Field value has to match with defined value. ' );
48+
49+ $ this ->assertEquals ($ record ->getModId (), 6 , 'It has ModID. ' );
50+ $ this ->assertEquals ($ record ->getRecordId (), 1 , 'It has RecordID. ' );
4751 $ pcounter = 0 ;
4852 $ this ->assertEquals ($ contacts ->count (), 3 , 'Checking the record number. ' );
4953 $ this ->assertEquals ($ contacts ->getTargetTable (), 'contact_to ' , 'Checking the table occurrence name. ' );
@@ -52,12 +56,13 @@ public function test_Query()
5256 $ this ->assertEquals ($ contacts ->getReturnedCount (), 3 , 'Checking the returned record number. ' );
5357
5458 foreach ($ contacts as $ item ) {
59+ $ item ->setPortalName ("contact_to " );
5560 if ($ pcounter === 0 ) {
56- $ this ->assertEquals ($ item ->field ("datetime " , " contact_to " ), '12/01/2009 15:23:00 ' , 'Portal field value has to match with defined value. ' );
61+ $ this ->assertEquals ($ item ->field ("datetime " ), '12/01/2009 15:23:00 ' , 'Portal field value has to match with defined value. ' );
5762 } else if ($ pcounter === 1 ) {
58- $ this ->assertEquals ($ item ->field ("datetime " , " contact_to " ), '12/02/2009 15:23:00 ' , 'Portal field value has to match with defined value. ' );
63+ $ this ->assertEquals ($ item ->field ("datetime " ), '12/02/2009 15:23:00 ' , 'Portal field value has to match with defined value. ' );
5964 } else if ($ pcounter === 2 ) {
60- $ this ->assertEquals ($ item ->field ("datetime " , " contact_to " ), '12/03/2009 15:23:00 ' , 'Portal field value has to match with defined value. ' );
65+ $ this ->assertEquals ($ item ->field ("datetime " ), '12/03/2009 15:23:00 ' , 'Portal field value has to match with defined value. ' );
6166 }
6267 $ pcounter += 1 ;
6368 }
@@ -110,6 +115,53 @@ public function test_ErrorQuery()
110115 $ this ->assertEquals ($ fm ->curlErrorCode (), 6 , 'The error code has to be 6. ' );
111116 }
112117
118+ public function test_SingleRecord ()
119+ {
120+ $ result = $ this ->fmdataapi ->person_layout ->query ();
121+ $ record = $ result ->getFirstRecord ();
122+ $ this ->assertEquals ($ record ->id , 1 , 'Field value has to match with defined value. ' );
123+ $ this ->assertEquals ($ record ->name , 'Masayuki Nii ' , 'Field value has to match with defined value. ' );
124+ $ this ->assertEquals ($ record ->mail , 'msyk@msyk.net ' , 'Field value has to match with defined value. ' );
125+ $ pcounter = 0 ;
126+ $ contacts = $ record ->Contact ;
127+ $ this ->assertEquals ($ contacts ->count (), 3 , 'Checking the record number. ' );
128+ $ this ->assertEquals ($ contacts ->getTargetTable (), 'contact_to ' , 'Checking the table occurrence name. ' );
129+ $ this ->assertNull ($ contacts ->getTotalCount (), 'Checking NULL as the total record number. ' );
130+ $ this ->assertEquals ($ contacts ->getFoundCount (), 3 , 'Checking the found record number. ' );
131+ $ this ->assertEquals ($ contacts ->getReturnedCount (), 3 , 'Checking the returned record number. ' );
132+
133+ foreach ($ contacts as $ item ) {
134+ if ($ pcounter === 0 ) {
135+ $ this ->assertEquals ($ item ->field ("datetime " , "contact_to " ), '12/01/2009 15:23:00 ' , 'Portal field value has to match with defined value. ' );
136+ } else if ($ pcounter === 1 ) {
137+ $ this ->assertEquals ($ item ->field ("datetime " , "contact_to " ), '12/02/2009 15:23:00 ' , 'Portal field value has to match with defined value. ' );
138+ } else if ($ pcounter === 2 ) {
139+ $ this ->assertEquals ($ item ->field ("datetime " , "contact_to " ), '12/03/2009 15:23:00 ' , 'Portal field value has to match with defined value. ' );
140+ }
141+ $ pcounter += 1 ;
142+ }
143+ $ this ->assertEquals ($ pcounter , 3 , 'Cheking the record number in portal. ' );
144+
145+ $ this ->assertEquals ($ record ->count (), 1 , 'The single record is just one record. ' );
146+ $ currentRecord = $ record ->current ();
147+ $ this ->assertEquals ($ currentRecord ->id , 1 , 'The single record can call current and return a Relation. ' );
148+ $ this ->assertEquals ($ record ->getPortalNames (), ['Contact ' , 'History ' ], 'The single record returns portal names. ' );
149+ $ this ->assertEquals ($ record ->getModId (), 6 , 'The single record returns ModID. ' );
150+ $ this ->assertEquals ($ record ->getRecordId (), 1 , 'The single record returns RecordID. ' );
151+ $ this ->assertEquals ($ record ->getTargetTable (), 'person_to ' , 'The single record returns the target table. ' );
152+
153+ $ pcount = 0 ;
154+ foreach ($ record as $ item ) {
155+ $ this ->assertEquals ($ item ->id , 1 , 'The single record can iterate. ' );
156+ $ pcount ++;
157+ }
158+ $ this ->assertEquals ($ pcount , 1 , 'The single record has to repeat just once. ' );
159+ $ this ->assertEquals ($ record ->getTotalCount (), 3 ,'Checking the total record number for queried data. ' );
160+ $ this ->assertEquals ($ record ->getFoundCount (), 3 , 'Checking the found record number for queried data. ' );
161+ $ this ->assertEquals ($ record ->getReturnedCount (), 1 , 'Checking the returned record number. ' );
162+
163+ }
164+
113165// public function test_OldVersionFMS()
114166// {
115167// $fm = new FMDataAPI("TestDB", "web", "password", "10.0.1.21", "443", "https", false, true);
0 commit comments