diff options
Diffstat (limited to 'tests/lib/Accounts/AccountTest.php')
-rw-r--r-- | tests/lib/Accounts/AccountTest.php | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/tests/lib/Accounts/AccountTest.php b/tests/lib/Accounts/AccountTest.php index 9c2a5333d20..0e0c42804e4 100644 --- a/tests/lib/Accounts/AccountTest.php +++ b/tests/lib/Accounts/AccountTest.php @@ -25,6 +25,7 @@ namespace Test\Accounts; use OC\Accounts\Account; use OC\Accounts\AccountProperty; +use OC\Accounts\AccountPropertyCollection; use OCP\Accounts\IAccountManager; use OCP\IUser; use Test\TestCase; @@ -49,7 +50,7 @@ class AccountTest extends TestCase { $this->assertEquals($property, $account->getProperty(IAccountManager::PROPERTY_WEBSITE)); } - public function testGetProperties() { + public function testGetAndGetAllProperties() { $user = $this->createMock(IUser::class); $properties = [ IAccountManager::PROPERTY_WEBSITE => new AccountProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::SCOPE_PUBLISHED, IAccountManager::NOT_VERIFIED, ''), @@ -59,7 +60,14 @@ class AccountTest extends TestCase { $account->setProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::SCOPE_PUBLISHED, IAccountManager::NOT_VERIFIED); $account->setProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::SCOPE_LOCAL, IAccountManager::VERIFIED); + $col = new AccountPropertyCollection(IAccountManager::COLLECTION_EMAIL); + $additionalProperty = new AccountProperty($col->getName(), 'second@example.org', IAccountManager::SCOPE_PUBLISHED, IAccountManager::NOT_VERIFIED, ''); + $col->addProperty($additionalProperty); + $account->setPropertyCollection($col); + $this->assertEquals($properties, $account->getProperties()); + $properties[] = $additionalProperty; + $this->assertEquals(array_values($properties), \iterator_to_array($account->getAllProperties())); } public function testGetFilteredProperties() { @@ -74,11 +82,20 @@ class AccountTest extends TestCase { $account->setProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::SCOPE_LOCAL, IAccountManager::VERIFIED); $account->setProperty(IAccountManager::PROPERTY_PHONE, '123456', IAccountManager::SCOPE_PUBLISHED, IAccountManager::VERIFIED); + $col = new AccountPropertyCollection(IAccountManager::COLLECTION_EMAIL); + $additionalProperty1 = new AccountProperty($col->getName(), 'second@example.org', IAccountManager::SCOPE_PUBLISHED, IAccountManager::NOT_VERIFIED, ''); + $additionalProperty2 = new AccountProperty($col->getName(), 'third@example.org', IAccountManager::SCOPE_PUBLISHED, IAccountManager::VERIFIED, ''); + $col->addProperty($additionalProperty1); + $col->addProperty($additionalProperty2); + $account->setPropertyCollection($col); + $this->assertEquals( [ IAccountManager::PROPERTY_WEBSITE => $properties[IAccountManager::PROPERTY_WEBSITE], IAccountManager::PROPERTY_PHONE => $properties[IAccountManager::PROPERTY_PHONE], + IAccountManager::COLLECTION_EMAIL . '#0' => $additionalProperty1, + IAccountManager::COLLECTION_EMAIL . '#1' => $additionalProperty2, ], $account->getFilteredProperties(IAccountManager::SCOPE_PUBLISHED) ); @@ -86,12 +103,16 @@ class AccountTest extends TestCase { [ IAccountManager::PROPERTY_EMAIL => $properties[IAccountManager::PROPERTY_EMAIL], IAccountManager::PROPERTY_PHONE => $properties[IAccountManager::PROPERTY_PHONE], + IAccountManager::COLLECTION_EMAIL . '#0' => $additionalProperty2, ], $account->getFilteredProperties(null, IAccountManager::VERIFIED) ); $this->assertEquals( - [IAccountManager::PROPERTY_PHONE => $properties[IAccountManager::PROPERTY_PHONE]], - $account->getFilteredProperties(IAccountManager::SCOPE_PUBLISHED, IAccountManager::VERIFIED) + [ + IAccountManager::PROPERTY_PHONE => $properties[IAccountManager::PROPERTY_PHONE], + IAccountManager::COLLECTION_EMAIL . '#0' => $additionalProperty2, + ], + $account->getFilteredProperties(IAccountManager::SCOPE_PUBLISHED, IAccountManager::VERIFIED), ); } |