1
0

AccountPropertyTest.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net>
  4. *
  5. * @author Julius Härtl <jus@bitgrid.net>
  6. *
  7. * @license GNU AGPL version 3 or any later version
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as
  11. * published by the Free Software Foundation, either version 3 of the
  12. * License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. */
  23. namespace Test\Accounts;
  24. use OC\Accounts\AccountProperty;
  25. use OCP\Accounts\IAccountManager;
  26. use Test\TestCase;
  27. /**
  28. * Class AccountPropertyTest
  29. *
  30. * @package Test\Accounts
  31. */
  32. class AccountPropertyTest extends TestCase {
  33. public function testConstructor() {
  34. $accountProperty = new AccountProperty(
  35. IAccountManager::PROPERTY_WEBSITE,
  36. 'https://example.com',
  37. IAccountManager::VISIBILITY_PUBLIC,
  38. IAccountManager::VERIFIED
  39. );
  40. $this->assertEquals(IAccountManager::PROPERTY_WEBSITE, $accountProperty->getName());
  41. $this->assertEquals('https://example.com', $accountProperty->getValue());
  42. $this->assertEquals(IAccountManager::VISIBILITY_PUBLIC, $accountProperty->getScope());
  43. $this->assertEquals(IAccountManager::VERIFIED, $accountProperty->getVerified());
  44. }
  45. public function testSetValue() {
  46. $accountProperty = new AccountProperty(
  47. IAccountManager::PROPERTY_WEBSITE,
  48. 'https://example.com',
  49. IAccountManager::VISIBILITY_PUBLIC,
  50. IAccountManager::VERIFIED
  51. );
  52. $actualReturn = $accountProperty->setValue('https://example.org');
  53. $this->assertEquals('https://example.org', $accountProperty->getValue());
  54. $this->assertEquals('https://example.org', $actualReturn->getValue());
  55. }
  56. public function testSetScope() {
  57. $accountProperty = new AccountProperty(
  58. IAccountManager::PROPERTY_WEBSITE,
  59. 'https://example.com',
  60. IAccountManager::VISIBILITY_PUBLIC,
  61. IAccountManager::VERIFIED
  62. );
  63. $actualReturn = $accountProperty->setScope(IAccountManager::VISIBILITY_PRIVATE);
  64. $this->assertEquals(IAccountManager::VISIBILITY_PRIVATE, $accountProperty->getScope());
  65. $this->assertEquals(IAccountManager::VISIBILITY_PRIVATE, $actualReturn->getScope());
  66. }
  67. public function testSetVerified() {
  68. $accountProperty = new AccountProperty(
  69. IAccountManager::PROPERTY_WEBSITE,
  70. 'https://example.com',
  71. IAccountManager::VISIBILITY_PUBLIC,
  72. IAccountManager::VERIFIED
  73. );
  74. $actualReturn = $accountProperty->setVerified(IAccountManager::NOT_VERIFIED);
  75. $this->assertEquals(IAccountManager::NOT_VERIFIED, $accountProperty->getVerified());
  76. $this->assertEquals(IAccountManager::NOT_VERIFIED, $actualReturn->getVerified());
  77. }
  78. public function testJsonSerialize() {
  79. $accountProperty = new AccountProperty(
  80. IAccountManager::PROPERTY_WEBSITE,
  81. 'https://example.com',
  82. IAccountManager::VISIBILITY_PUBLIC,
  83. IAccountManager::VERIFIED
  84. );
  85. $this->assertEquals([
  86. 'name' => IAccountManager::PROPERTY_WEBSITE,
  87. 'value' => 'https://example.com',
  88. 'scope' => IAccountManager::VISIBILITY_PUBLIC,
  89. 'verified' => IAccountManager::VERIFIED
  90. ], $accountProperty->jsonSerialize());
  91. }
  92. }