44 * SPDX-FileCopyrightText: 2016 ownCloud, Inc. 
55 * SPDX-License-Identifier: AGPL-3.0-or-later 
66 */ 
7+ 
8+ use  Behat \Gherkin \Node \TableNode ;
79use  GuzzleHttp \Client ;
810use  GuzzleHttp \Message \ResponseInterface ;
911use  PHPUnit \Framework \Assert ;
@@ -124,7 +126,7 @@ public function creatingTheUser($user, $displayname = '') {
124126	 * @Then /^user "([^"]*)" has$/ 
125127	 * 
126128	 * @param string $user 
127- 	 * @param \Behat\Gherkin\Node\ TableNode|null $settings 
129+ 	 * @param TableNode|null $settings 
128130	 */ 
129131	public  function  userHasSetting ($ user$ settings
130132		$ fullUrl$ this baseUrl  . "v {$ this apiVersion }.php/cloud/users/ $ user ;
@@ -145,12 +147,43 @@ public function userHasSetting($user, $settings) {
145147			if  (isset ($ value'element ' ]) && in_array ($ setting0 ], ['additional_mail ' , 'additional_mailScope ' ], true )) {
146148				$ expectedValuesexplode ('; ' , $ setting1 ]);
147149				foreach  ($ expectedValuesas  $ expected
148- 					Assert::assertTrue (in_array ($ expected$ value'element ' ], true ));
150+ 					Assert::assertTrue (in_array ($ expected$ value'element ' ], true ),  ' Data wrong for field:  '  .  $ setting [ 0 ] );
149151				}
150152			} elseif  (isset ($ value0 ])) {
151- 				Assert::assertEqualsCanonicalizing ($ setting1 ], $ value0 ]);
153+ 				Assert::assertEqualsCanonicalizing ($ setting1 ], $ value0 ],  ' Data wrong for field:  '  .  $ setting [ 0 ] );
152154			} else  {
153- 				Assert::assertEquals ('' , $ setting1 ]);
155+ 				Assert::assertEquals ('' , $ setting1 ], 'Data wrong for field:  '  . $ setting0 ]);
156+ 			}
157+ 		}
158+ 	}
159+ 
160+ 	/** 
161+ 	 * @Then /^user "([^"]*)" has the following profile data$/ 
162+ 	 */ 
163+ 	public  function  userHasProfileData (string  $ userTableNode $ settingsvoid  {
164+ 		$ fullUrl$ this baseUrl  . "v {$ this apiVersion }.php/profile/ $ user ;
165+ 		$ clientnew  Client ();
166+ 		$ options
167+ 		if  ($ this currentUser  === 'admin ' ) {
168+ 			$ options'auth ' ] = $ this adminUser ;
169+ 		} else  {
170+ 			$ options'auth ' ] = [$ this currentUser , $ this regularUser ];
171+ 		}
172+ 		$ options'headers ' ] = [
173+ 			'OCS-APIREQUEST '  => 'true ' ,
174+ 			'Accept '  => 'application/json ' ,
175+ 		];
176+ 
177+ 		$ response$ clientget ($ fullUrl$ options
178+ 		$ body$ responsegetBody ()->getContents ();
179+ 		$ datajson_decode ($ bodytrue );
180+ 		$ data$ data'ocs ' ]['data ' ];
181+ 		foreach  ($ settingsgetRows () as  $ setting
182+ 			Assert::assertArrayHasKey ($ setting0 ], $ data'Profile data field missing:  '  . $ setting0 ]);
183+ 			if  ($ setting1 ] === 'NULL ' ) {
184+ 				Assert::assertNull ($ data$ setting0 ]], 'Profile data wrong for field:  '  . $ setting0 ]);
185+ 			} else  {
186+ 				Assert::assertEquals ($ setting1 ], $ data$ setting0 ]], 'Profile data wrong for field:  '  . $ setting0 ]);
154187			}
155188		}
156189	}
@@ -159,7 +192,7 @@ public function userHasSetting($user, $settings) {
159192	 * @Then /^group "([^"]*)" has$/ 
160193	 * 
161194	 * @param string $user 
162- 	 * @param \Behat\Gherkin\Node\ TableNode|null $settings 
195+ 	 * @param TableNode|null $settings 
163196	 */ 
164197	public  function  groupHasSetting ($ group$ settings
165198		$ fullUrl$ this baseUrl  . "v {$ this apiVersion }.php/cloud/groups/details?search= $ group ;
@@ -191,7 +224,7 @@ public function groupHasSetting($group, $settings) {
191224	 * @Then /^user "([^"]*)" has editable fields$/ 
192225	 * 
193226	 * @param string $user 
194- 	 * @param \Behat\Gherkin\Node\ TableNode|null $fields 
227+ 	 * @param TableNode|null $fields 
195228	 */ 
196229	public  function  userHasEditableFields ($ user$ fields
197230		$ fullUrl$ this baseUrl  . "v {$ this apiVersion }.php/cloud/user/fields " ;
@@ -221,9 +254,9 @@ public function userHasEditableFields($user, $fields) {
221254	 * @Then /^search users by phone for region "([^"]*)" with$/ 
222255	 * 
223256	 * @param string $user 
224- 	 * @param \Behat\Gherkin\Node\ TableNode|null $settings 
257+ 	 * @param TableNode|null $settings 
225258	 */ 
226- 	public  function  searchUserByPhone ($ region\ Behat \ Gherkin \ Node \ TableNode $ searchTable
259+ 	public  function  searchUserByPhone ($ regionTableNode $ searchTable
227260		$ fullUrl$ this baseUrl  . "v {$ this apiVersion }.php/cloud/users/search/by-phone " ;
228261		$ clientnew  Client ();
229262		$ options
@@ -624,10 +657,10 @@ public function userIsNotSubadminOfGroup($user, $group) {
624657
625658	/** 
626659	 * @Then /^users returned are$/ 
627- 	 * @param \Behat\Gherkin\Node\ TableNode|null $usersList 
660+ 	 * @param TableNode|null $usersList 
628661	 */ 
629662	public  function  theUsersShouldBe ($ usersList
630- 		if  ($ usersListinstanceof  \ Behat \ Gherkin \ Node \ TableNode) {
663+ 		if  ($ usersListinstanceof  TableNode) {
631664			$ users$ usersListgetRows ();
632665			$ usersSimplified$ this simplifyArray ($ users
633666			$ respondedArray$ this getArrayOfUsersResponded ($ this response );
@@ -637,10 +670,10 @@ public function theUsersShouldBe($usersList) {
637670
638671	/** 
639672	 * @Then /^phone matches returned are$/ 
640- 	 * @param \Behat\Gherkin\Node\ TableNode|null $usersList 
673+ 	 * @param TableNode|null $usersList 
641674	 */ 
642675	public  function  thePhoneUsersShouldBe ($ usersList
643- 		if  ($ usersListinstanceof  \ Behat \ Gherkin \ Node \ TableNode) {
676+ 		if  ($ usersListinstanceof  TableNode) {
644677			$ users$ usersListgetRowsHash ();
645678			$ listCheckedElementssimplexml_load_string ($ this response ->getBody ())->data ;
646679			$ respondedArrayjson_decode (json_encode ($ listCheckedElementstrue );
@@ -650,10 +683,10 @@ public function thePhoneUsersShouldBe($usersList) {
650683
651684	/** 
652685	 * @Then /^detailed users returned are$/ 
653- 	 * @param \Behat\Gherkin\Node\ TableNode|null $usersList 
686+ 	 * @param TableNode|null $usersList 
654687	 */ 
655688	public  function  theDetailedUsersShouldBe ($ usersList
656- 		if  ($ usersListinstanceof  \ Behat \ Gherkin \ Node \ TableNode) {
689+ 		if  ($ usersListinstanceof  TableNode) {
657690			$ users$ usersListgetRows ();
658691			$ usersSimplified$ this simplifyArray ($ users
659692			$ respondedArray$ this getArrayOfDetailedUsersResponded ($ this response );
@@ -664,10 +697,10 @@ public function theDetailedUsersShouldBe($usersList) {
664697
665698	/** 
666699	 * @Then /^groups returned are$/ 
667- 	 * @param \Behat\Gherkin\Node\ TableNode|null $groupsList 
700+ 	 * @param TableNode|null $groupsList 
668701	 */ 
669702	public  function  theGroupsShouldBe ($ groupsList
670- 		if  ($ groupsListinstanceof  \ Behat \ Gherkin \ Node \ TableNode) {
703+ 		if  ($ groupsListinstanceof  TableNode) {
671704			$ groups$ groupsListgetRows ();
672705			$ groupsSimplified$ this simplifyArray ($ groups
673706			$ respondedArray$ this getArrayOfGroupsResponded ($ this response );
@@ -677,10 +710,10 @@ public function theGroupsShouldBe($groupsList) {
677710
678711	/** 
679712	 * @Then /^subadmin groups returned are$/ 
680- 	 * @param \Behat\Gherkin\Node\ TableNode|null $groupsList 
713+ 	 * @param TableNode|null $groupsList 
681714	 */ 
682715	public  function  theSubadminGroupsShouldBe ($ groupsList
683- 		if  ($ groupsListinstanceof  \ Behat \ Gherkin \ Node \ TableNode) {
716+ 		if  ($ groupsListinstanceof  TableNode) {
684717			$ groups$ groupsListgetRows ();
685718			$ groupsSimplified$ this simplifyArray ($ groups
686719			$ respondedArray$ this getArrayOfSubadminsResponded ($ this response );
@@ -690,10 +723,10 @@ public function theSubadminGroupsShouldBe($groupsList) {
690723
691724	/** 
692725	 * @Then /^apps returned are$/ 
693- 	 * @param \Behat\Gherkin\Node\ TableNode|null $appList 
726+ 	 * @param TableNode|null $appList 
694727	 */ 
695728	public  function  theAppsShouldBe ($ appList
696- 		if  ($ appListinstanceof  \ Behat \ Gherkin \ Node \ TableNode) {
729+ 		if  ($ appListinstanceof  TableNode) {
697730			$ apps$ appListgetRows ();
698731			$ appsSimplified$ this simplifyArray ($ apps
699732			$ respondedArray$ this getArrayOfAppsResponded ($ this response );
@@ -703,7 +736,7 @@ public function theAppsShouldBe($appList) {
703736
704737	/** 
705738	 * @Then /^subadmin users returned are$/ 
706- 	 * @param \Behat\Gherkin\Node\ TableNode|null $groupsList 
739+ 	 * @param TableNode|null $groupsList 
707740	 */ 
708741	public  function  theSubadminUsersShouldBe ($ groupsList
709742		$ this theSubadminGroupsShouldBe ($ groupsList
@@ -882,7 +915,7 @@ public function userIsEnabled($user) {
882915	 * @param string $quota 
883916	 */ 
884917	public  function  userHasAQuotaOf ($ user$ quota
885- 		$ bodynew  \ Behat \ Gherkin \ Node \ TableNode ([
918+ 		$ bodynew  TableNode ([
886919			0  => ['key ' , 'quota ' ],
887920			1  => ['value ' , $ quota
888921		]);
@@ -950,7 +983,7 @@ public function cleanupGroups() {
950983	/** 
951984	 * @Then /^user "([^"]*)" has not$/ 
952985	 */ 
953- 	public  function  userHasNotSetting ($ user\ Behat \ Gherkin \ Node \ TableNode $ settings
986+ 	public  function  userHasNotSetting ($ userTableNode $ settings
954987		$ fullUrl$ this baseUrl  . "v {$ this apiVersion }.php/cloud/users/ $ user ;
955988		$ clientnew  Client ();
956989		$ options
0 commit comments