1
0

ContactsMenu.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. use PHPUnit\Framework\Assert;
  7. trait ContactsMenu {
  8. // BasicStructure trait is expected to be used in the class that uses this
  9. // trait.
  10. /**
  11. * @When /^searching for contacts matching with "([^"]*)"$/
  12. *
  13. * @param string $filter
  14. */
  15. public function searchingForContactsMatchingWith(string $filter) {
  16. $url = '/index.php/contactsmenu/contacts';
  17. $parameters[] = 'filter=' . $filter;
  18. $url .= '?' . implode('&', $parameters);
  19. $this->sendingAToWithRequesttoken('POST', $url);
  20. }
  21. /**
  22. * @Then /^the list of searched contacts has "(\d+)" contacts$/
  23. */
  24. public function theListOfSearchedContactsHasContacts(int $count) {
  25. $this->theHTTPStatusCodeShouldBe(200);
  26. $searchedContacts = json_decode($this->response->getBody(), $asAssociativeArray = true)['contacts'];
  27. Assert::assertEquals($count, count($searchedContacts));
  28. }
  29. /**
  30. * @Then /^searched contact "(\d+)" is named "([^"]*)"$/
  31. *
  32. * @param int $index
  33. * @param string $expectedName
  34. */
  35. public function searchedContactXIsNamed(int $index, string $expectedName) {
  36. $searchedContacts = json_decode($this->response->getBody(), $asAssociativeArray = true)['contacts'];
  37. $searchedContact = $searchedContacts[$index];
  38. Assert::assertEquals($expectedName, $searchedContact['fullName']);
  39. }
  40. }