diff options
author | Julius Härtl <jus@bitgrid.net> | 2018-10-15 13:29:53 +0200 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2018-10-15 13:30:31 +0200 |
commit | b9a87a69cf53516a20b4dd00125d5fcf5fb956de (patch) | |
tree | 0557c7ea9218b4a7e2aa30910dc878b91262ce91 /tests/lib/Accounts | |
parent | 90cdd0a12a79f1d334077dd7b7b9a83ef9f7ea55 (diff) | |
download | nextcloud-server-b9a87a69cf53516a20b4dd00125d5fcf5fb956de.tar.gz nextcloud-server-b9a87a69cf53516a20b4dd00125d5fcf5fb956de.zip |
Use IAccountManager constants
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'tests/lib/Accounts')
-rw-r--r-- | tests/lib/Accounts/AccountPropertyTest.php | 58 | ||||
-rw-r--r-- | tests/lib/Accounts/AccountTest.php | 52 | ||||
-rw-r--r-- | tests/lib/Accounts/AccountsManagerTest.php | 25 |
3 files changed, 67 insertions, 68 deletions
diff --git a/tests/lib/Accounts/AccountPropertyTest.php b/tests/lib/Accounts/AccountPropertyTest.php index 5d71287fedb..988fd64001d 100644 --- a/tests/lib/Accounts/AccountPropertyTest.php +++ b/tests/lib/Accounts/AccountPropertyTest.php @@ -23,10 +23,8 @@ namespace Test\Accounts; -use OC\Accounts\Account; -use OC\Accounts\AccountManager; use OC\Accounts\AccountProperty; - +use OCP\Accounts\IAccountManager; use Test\TestCase; /** @@ -38,23 +36,23 @@ class AccountPropertyTest extends TestCase { public function testConstructor() { $accountProperty = new AccountProperty( - AccountManager::PROPERTY_WEBSITE, + IAccountManager::PROPERTY_WEBSITE, 'https://example.com', - AccountManager::VISIBILITY_PUBLIC, - AccountManager::VERIFIED + IAccountManager::VISIBILITY_PUBLIC, + IAccountManager::VERIFIED ); - $this->assertEquals(AccountManager::PROPERTY_WEBSITE, $accountProperty->getName()); + $this->assertEquals(IAccountManager::PROPERTY_WEBSITE, $accountProperty->getName()); $this->assertEquals('https://example.com', $accountProperty->getValue()); - $this->assertEquals(AccountManager::VISIBILITY_PUBLIC, $accountProperty->getScope()); - $this->assertEquals(AccountManager::VERIFIED, $accountProperty->getVerified()); + $this->assertEquals(IAccountManager::VISIBILITY_PUBLIC, $accountProperty->getScope()); + $this->assertEquals(IAccountManager::VERIFIED, $accountProperty->getVerified()); } public function testSetValue() { $accountProperty = new AccountProperty( - AccountManager::PROPERTY_WEBSITE, + IAccountManager::PROPERTY_WEBSITE, 'https://example.com', - AccountManager::VISIBILITY_PUBLIC, - AccountManager::VERIFIED + IAccountManager::VISIBILITY_PUBLIC, + IAccountManager::VERIFIED ); $actualReturn = $accountProperty->setValue('https://example.org'); $this->assertEquals('https://example.org', $accountProperty->getValue()); @@ -63,40 +61,40 @@ class AccountPropertyTest extends TestCase { public function testSetScope() { $accountProperty = new AccountProperty( - AccountManager::PROPERTY_WEBSITE, + IAccountManager::PROPERTY_WEBSITE, 'https://example.com', - AccountManager::VISIBILITY_PUBLIC, - AccountManager::VERIFIED + IAccountManager::VISIBILITY_PUBLIC, + IAccountManager::VERIFIED ); - $actualReturn = $accountProperty->setScope(AccountManager::VISIBILITY_PRIVATE); - $this->assertEquals(AccountManager::VISIBILITY_PRIVATE, $accountProperty->getScope()); - $this->assertEquals(AccountManager::VISIBILITY_PRIVATE, $actualReturn->getScope()); + $actualReturn = $accountProperty->setScope(IAccountManager::VISIBILITY_PRIVATE); + $this->assertEquals(IAccountManager::VISIBILITY_PRIVATE, $accountProperty->getScope()); + $this->assertEquals(IAccountManager::VISIBILITY_PRIVATE, $actualReturn->getScope()); } public function testSetVerified() { $accountProperty = new AccountProperty( - AccountManager::PROPERTY_WEBSITE, + IAccountManager::PROPERTY_WEBSITE, 'https://example.com', - AccountManager::VISIBILITY_PUBLIC, - AccountManager::VERIFIED + IAccountManager::VISIBILITY_PUBLIC, + IAccountManager::VERIFIED ); - $actualReturn = $accountProperty->setVerified(AccountManager::NOT_VERIFIED); - $this->assertEquals(AccountManager::NOT_VERIFIED, $accountProperty->getVerified()); - $this->assertEquals(AccountManager::NOT_VERIFIED, $actualReturn->getVerified()); + $actualReturn = $accountProperty->setVerified(IAccountManager::NOT_VERIFIED); + $this->assertEquals(IAccountManager::NOT_VERIFIED, $accountProperty->getVerified()); + $this->assertEquals(IAccountManager::NOT_VERIFIED, $actualReturn->getVerified()); } public function testJsonSerialize() { $accountProperty = new AccountProperty( - AccountManager::PROPERTY_WEBSITE, + IAccountManager::PROPERTY_WEBSITE, 'https://example.com', - AccountManager::VISIBILITY_PUBLIC, - AccountManager::VERIFIED + IAccountManager::VISIBILITY_PUBLIC, + IAccountManager::VERIFIED ); $this->assertEquals([ - 'name' => AccountManager::PROPERTY_WEBSITE, + 'name' => IAccountManager::PROPERTY_WEBSITE, 'value' => 'https://example.com', - 'scope' => AccountManager::VISIBILITY_PUBLIC, - 'verified' => AccountManager::VERIFIED + 'scope' => IAccountManager::VISIBILITY_PUBLIC, + 'verified' => IAccountManager::VERIFIED ], $accountProperty->jsonSerialize()); } diff --git a/tests/lib/Accounts/AccountTest.php b/tests/lib/Accounts/AccountTest.php index 3fc73f75af6..6d0e187c433 100644 --- a/tests/lib/Accounts/AccountTest.php +++ b/tests/lib/Accounts/AccountTest.php @@ -24,8 +24,8 @@ namespace Test\Accounts; use OC\Accounts\Account; -use OC\Accounts\AccountManager; use OC\Accounts\AccountProperty; +use OCP\Accounts\IAccountManager; use OCP\IUser; use Test\TestCase; @@ -44,21 +44,21 @@ class AccountTest extends TestCase { public function testSetProperty() { $user = $this->createMock(IUser::class); - $property = new AccountProperty(AccountManager::PROPERTY_WEBSITE, 'https://example.com', AccountManager::VISIBILITY_PUBLIC, AccountManager::NOT_VERIFIED); + $property = new AccountProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::NOT_VERIFIED); $account = new Account($user); - $account->setProperty(AccountManager::PROPERTY_WEBSITE, 'https://example.com', AccountManager::VISIBILITY_PUBLIC, AccountManager::NOT_VERIFIED); - $this->assertEquals($property, $account->getProperty(AccountManager::PROPERTY_WEBSITE)); + $account->setProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::NOT_VERIFIED); + $this->assertEquals($property, $account->getProperty(IAccountManager::PROPERTY_WEBSITE)); } public function testGetProperties() { $user = $this->createMock(IUser::class); $properties = [ - AccountManager::PROPERTY_WEBSITE => new AccountProperty(AccountManager::PROPERTY_WEBSITE, 'https://example.com', AccountManager::VISIBILITY_PUBLIC, AccountManager::NOT_VERIFIED), - AccountManager::PROPERTY_EMAIL => new AccountProperty(AccountManager::PROPERTY_EMAIL, 'user@example.com', AccountManager::VISIBILITY_PRIVATE, AccountManager::VERIFIED) + IAccountManager::PROPERTY_WEBSITE => new AccountProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::NOT_VERIFIED), + IAccountManager::PROPERTY_EMAIL => new AccountProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::VISIBILITY_PRIVATE, IAccountManager::VERIFIED) ]; $account = new Account($user); - $account->setProperty(AccountManager::PROPERTY_WEBSITE, 'https://example.com', AccountManager::VISIBILITY_PUBLIC, AccountManager::NOT_VERIFIED); - $account->setProperty(AccountManager::PROPERTY_EMAIL, 'user@example.com', AccountManager::VISIBILITY_PRIVATE, AccountManager::VERIFIED); + $account->setProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::NOT_VERIFIED); + $account->setProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::VISIBILITY_PRIVATE, IAccountManager::VERIFIED); $this->assertEquals($properties, $account->getProperties()); } @@ -66,45 +66,45 @@ class AccountTest extends TestCase { public function testGetFilteredProperties() { $user = $this->createMock(IUser::class); $properties = [ - AccountManager::PROPERTY_WEBSITE => new AccountProperty(AccountManager::PROPERTY_WEBSITE, 'https://example.com', AccountManager::VISIBILITY_PUBLIC, AccountManager::NOT_VERIFIED), - AccountManager::PROPERTY_EMAIL => new AccountProperty(AccountManager::PROPERTY_EMAIL, 'user@example.com', AccountManager::VISIBILITY_PRIVATE, AccountManager::VERIFIED), - AccountManager::PROPERTY_PHONE => new AccountProperty(AccountManager::PROPERTY_PHONE, '123456', AccountManager::VISIBILITY_PUBLIC, AccountManager::VERIFIED), + IAccountManager::PROPERTY_WEBSITE => new AccountProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::NOT_VERIFIED), + IAccountManager::PROPERTY_EMAIL => new AccountProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::VISIBILITY_PRIVATE, IAccountManager::VERIFIED), + IAccountManager::PROPERTY_PHONE => new AccountProperty(IAccountManager::PROPERTY_PHONE, '123456', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::VERIFIED), ]; $account = new Account($user); - $account->setProperty(AccountManager::PROPERTY_WEBSITE, 'https://example.com', AccountManager::VISIBILITY_PUBLIC, AccountManager::NOT_VERIFIED); - $account->setProperty(AccountManager::PROPERTY_EMAIL, 'user@example.com', AccountManager::VISIBILITY_PRIVATE, AccountManager::VERIFIED); - $account->setProperty(AccountManager::PROPERTY_PHONE, '123456', AccountManager::VISIBILITY_PUBLIC, AccountManager::VERIFIED); + $account->setProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::NOT_VERIFIED); + $account->setProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::VISIBILITY_PRIVATE, IAccountManager::VERIFIED); + $account->setProperty(IAccountManager::PROPERTY_PHONE, '123456', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::VERIFIED); $this->assertEquals( [ - AccountManager::PROPERTY_WEBSITE => $properties[AccountManager::PROPERTY_WEBSITE], - AccountManager::PROPERTY_PHONE => $properties[AccountManager::PROPERTY_PHONE], + IAccountManager::PROPERTY_WEBSITE => $properties[IAccountManager::PROPERTY_WEBSITE], + IAccountManager::PROPERTY_PHONE => $properties[IAccountManager::PROPERTY_PHONE], ], - $account->getFilteredProperties(AccountManager::VISIBILITY_PUBLIC) + $account->getFilteredProperties(IAccountManager::VISIBILITY_PUBLIC) ); $this->assertEquals( [ - AccountManager::PROPERTY_EMAIL => $properties[AccountManager::PROPERTY_EMAIL], - AccountManager::PROPERTY_PHONE => $properties[AccountManager::PROPERTY_PHONE], + IAccountManager::PROPERTY_EMAIL => $properties[IAccountManager::PROPERTY_EMAIL], + IAccountManager::PROPERTY_PHONE => $properties[IAccountManager::PROPERTY_PHONE], ], - $account->getFilteredProperties(null, AccountManager::VERIFIED) + $account->getFilteredProperties(null, IAccountManager::VERIFIED) ); $this->assertEquals( - [AccountManager::PROPERTY_PHONE => $properties[AccountManager::PROPERTY_PHONE]], - $account->getFilteredProperties(AccountManager::VISIBILITY_PUBLIC, AccountManager::VERIFIED) + [IAccountManager::PROPERTY_PHONE => $properties[IAccountManager::PROPERTY_PHONE]], + $account->getFilteredProperties(IAccountManager::VISIBILITY_PUBLIC, IAccountManager::VERIFIED) ); } public function testJsonSerialize() { $user = $this->createMock(IUser::class); $properties = [ - AccountManager::PROPERTY_WEBSITE => new AccountProperty(AccountManager::PROPERTY_WEBSITE, 'https://example.com', AccountManager::VISIBILITY_PUBLIC, AccountManager::NOT_VERIFIED), - AccountManager::PROPERTY_EMAIL => new AccountProperty(AccountManager::PROPERTY_EMAIL, 'user@example.com', AccountManager::VISIBILITY_PRIVATE, AccountManager::VERIFIED) + IAccountManager::PROPERTY_WEBSITE => new AccountProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::NOT_VERIFIED), + IAccountManager::PROPERTY_EMAIL => new AccountProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::VISIBILITY_PRIVATE, IAccountManager::VERIFIED) ]; $account = new Account($user); - $account->setProperty(AccountManager::PROPERTY_WEBSITE, 'https://example.com', AccountManager::VISIBILITY_PUBLIC, AccountManager::NOT_VERIFIED); - $account->setProperty(AccountManager::PROPERTY_EMAIL, 'user@example.com', AccountManager::VISIBILITY_PRIVATE, AccountManager::VERIFIED); + $account->setProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::NOT_VERIFIED); + $account->setProperty(IAccountManager::PROPERTY_EMAIL, 'user@example.com', IAccountManager::VISIBILITY_PRIVATE, IAccountManager::VERIFIED); $this->assertEquals($properties, $account->jsonSerialize()); } diff --git a/tests/lib/Accounts/AccountsManagerTest.php b/tests/lib/Accounts/AccountsManagerTest.php index dee8ba5d810..bff3b353a1e 100644 --- a/tests/lib/Accounts/AccountsManagerTest.php +++ b/tests/lib/Accounts/AccountsManagerTest.php @@ -25,6 +25,7 @@ namespace Test\Accounts; use OC\Accounts\Account; use OC\Accounts\AccountManager; +use OCP\Accounts\IAccountManager; use OCP\BackgroundJob\IJobList; use OCP\IUser; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -261,29 +262,29 @@ class AccountsManagerTest extends TestCase { $user = $this->createMock(IUser::class); $data = [ - AccountManager::PROPERTY_TWITTER => + IAccountManager::PROPERTY_TWITTER => [ 'value' => '@twitterhandle', - 'scope' => AccountManager::VISIBILITY_PRIVATE, - 'verified' => AccountManager::NOT_VERIFIED, + 'scope' => IAccountManager::VISIBILITY_PRIVATE, + 'verified' => IAccountManager::NOT_VERIFIED, ], - AccountManager::PROPERTY_EMAIL => + IAccountManager::PROPERTY_EMAIL => [ 'value' => 'test@example.com', - 'scope' => AccountManager::VISIBILITY_PUBLIC, - 'verified' => AccountManager::VERIFICATION_IN_PROGRESS, + 'scope' => IAccountManager::VISIBILITY_PUBLIC, + 'verified' => IAccountManager::VERIFICATION_IN_PROGRESS, ], - AccountManager::PROPERTY_WEBSITE => + IAccountManager::PROPERTY_WEBSITE => [ 'value' => 'https://example.com', - 'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY, - 'verified' => AccountManager::VERIFIED, + 'scope' => IAccountManager::VISIBILITY_CONTACTS_ONLY, + 'verified' => IAccountManager::VERIFIED, ], ]; $expected = new Account($user); - $expected->setProperty(AccountManager::PROPERTY_TWITTER, '@twitterhandle', AccountManager::VISIBILITY_PRIVATE, AccountManager::NOT_VERIFIED); - $expected->setProperty(AccountManager::PROPERTY_EMAIL, 'test@example.com', AccountManager::VISIBILITY_PUBLIC, AccountManager::VERIFICATION_IN_PROGRESS); - $expected->setProperty(AccountManager::PROPERTY_WEBSITE, 'https://example.com', AccountManager::VISIBILITY_CONTACTS_ONLY, AccountManager::VERIFIED); + $expected->setProperty(IAccountManager::PROPERTY_TWITTER, '@twitterhandle', IAccountManager::VISIBILITY_PRIVATE, IAccountManager::NOT_VERIFIED); + $expected->setProperty(IAccountManager::PROPERTY_EMAIL, 'test@example.com', IAccountManager::VISIBILITY_PUBLIC, IAccountManager::VERIFICATION_IN_PROGRESS); + $expected->setProperty(IAccountManager::PROPERTY_WEBSITE, 'https://example.com', IAccountManager::VISIBILITY_CONTACTS_ONLY, IAccountManager::VERIFIED); $accountManager->expects($this->once()) ->method('getUser') |