@@ -13,78 +13,78 @@ |
||
13 | 13 | |
14 | 14 | class LegacyBackendTest extends \Test\TestCase { |
15 | 15 | |
16 | - /** |
|
17 | - * @return MissingDependency[] |
|
18 | - */ |
|
19 | - public static function checkDependencies(): array { |
|
20 | - return [ |
|
21 | - (new MissingDependency('abc'))->setMessage('foobar') |
|
22 | - ]; |
|
23 | - } |
|
16 | + /** |
|
17 | + * @return MissingDependency[] |
|
18 | + */ |
|
19 | + public static function checkDependencies(): array { |
|
20 | + return [ |
|
21 | + (new MissingDependency('abc'))->setMessage('foobar') |
|
22 | + ]; |
|
23 | + } |
|
24 | 24 | |
25 | - public function testConstructor(): void { |
|
26 | - $auth = $this->createMock(Builtin::class); |
|
25 | + public function testConstructor(): void { |
|
26 | + $auth = $this->createMock(Builtin::class); |
|
27 | 27 | |
28 | - $class = self::class; |
|
29 | - $definition = [ |
|
30 | - 'configuration' => [ |
|
31 | - 'textfield' => 'Text field', |
|
32 | - 'passwordfield' => '*Password field', |
|
33 | - 'checkbox' => '!Checkbox', |
|
34 | - 'optionaltext' => '&Optional text field', |
|
35 | - 'optionalpassword' => '&*Optional password field', |
|
36 | - ], |
|
37 | - 'backend' => 'Backend text', |
|
38 | - 'priority' => 123, |
|
39 | - 'custom' => 'foo/bar.js', |
|
40 | - 'has_dependencies' => true, |
|
41 | - ]; |
|
28 | + $class = self::class; |
|
29 | + $definition = [ |
|
30 | + 'configuration' => [ |
|
31 | + 'textfield' => 'Text field', |
|
32 | + 'passwordfield' => '*Password field', |
|
33 | + 'checkbox' => '!Checkbox', |
|
34 | + 'optionaltext' => '&Optional text field', |
|
35 | + 'optionalpassword' => '&*Optional password field', |
|
36 | + ], |
|
37 | + 'backend' => 'Backend text', |
|
38 | + 'priority' => 123, |
|
39 | + 'custom' => 'foo/bar.js', |
|
40 | + 'has_dependencies' => true, |
|
41 | + ]; |
|
42 | 42 | |
43 | - $backend = new LegacyBackend($class, $definition, $auth); |
|
43 | + $backend = new LegacyBackend($class, $definition, $auth); |
|
44 | 44 | |
45 | - $this->assertEquals(self::class, $backend->getStorageClass()); |
|
46 | - $this->assertEquals('Backend text', $backend->getText()); |
|
47 | - $this->assertEquals(123, $backend->getPriority()); |
|
48 | - $this->assertContains('foo/bar.js', $backend->getCustomJs()); |
|
49 | - $this->assertArrayHasKey('builtin', $backend->getAuthSchemes()); |
|
50 | - $this->assertEquals($auth, $backend->getLegacyAuthMechanism()); |
|
45 | + $this->assertEquals(self::class, $backend->getStorageClass()); |
|
46 | + $this->assertEquals('Backend text', $backend->getText()); |
|
47 | + $this->assertEquals(123, $backend->getPriority()); |
|
48 | + $this->assertContains('foo/bar.js', $backend->getCustomJs()); |
|
49 | + $this->assertArrayHasKey('builtin', $backend->getAuthSchemes()); |
|
50 | + $this->assertEquals($auth, $backend->getLegacyAuthMechanism()); |
|
51 | 51 | |
52 | - $dependencies = $backend->checkDependencies(); |
|
53 | - $this->assertCount(1, $dependencies); |
|
54 | - $this->assertEquals('abc', $dependencies[0]->getDependency()); |
|
55 | - $this->assertEquals('foobar', $dependencies[0]->getMessage()); |
|
52 | + $dependencies = $backend->checkDependencies(); |
|
53 | + $this->assertCount(1, $dependencies); |
|
54 | + $this->assertEquals('abc', $dependencies[0]->getDependency()); |
|
55 | + $this->assertEquals('foobar', $dependencies[0]->getMessage()); |
|
56 | 56 | |
57 | - $parameters = $backend->getParameters(); |
|
58 | - $this->assertEquals('Text field', $parameters['textfield']->getText()); |
|
59 | - $this->assertEquals(DefinitionParameter::VALUE_TEXT, $parameters['textfield']->getType()); |
|
60 | - $this->assertEquals(DefinitionParameter::FLAG_NONE, $parameters['textfield']->getFlags()); |
|
61 | - $this->assertEquals('Password field', $parameters['passwordfield']->getText()); |
|
62 | - $this->assertEquals(DefinitionParameter::VALUE_PASSWORD, $parameters['passwordfield']->getType()); |
|
63 | - $this->assertEquals(DefinitionParameter::FLAG_NONE, $parameters['passwordfield']->getFlags()); |
|
64 | - $this->assertEquals('Checkbox', $parameters['checkbox']->getText()); |
|
65 | - $this->assertEquals(DefinitionParameter::VALUE_BOOLEAN, $parameters['checkbox']->getType()); |
|
66 | - $this->assertEquals(DefinitionParameter::FLAG_NONE, $parameters['checkbox']->getFlags()); |
|
67 | - $this->assertEquals('Optional text field', $parameters['optionaltext']->getText()); |
|
68 | - $this->assertEquals(DefinitionParameter::VALUE_TEXT, $parameters['optionaltext']->getType()); |
|
69 | - $this->assertEquals(DefinitionParameter::FLAG_OPTIONAL, $parameters['optionaltext']->getFlags()); |
|
70 | - $this->assertEquals('Optional password field', $parameters['optionalpassword']->getText()); |
|
71 | - $this->assertEquals(DefinitionParameter::VALUE_PASSWORD, $parameters['optionalpassword']->getType()); |
|
72 | - $this->assertEquals(DefinitionParameter::FLAG_OPTIONAL, $parameters['optionalpassword']->getFlags()); |
|
73 | - } |
|
57 | + $parameters = $backend->getParameters(); |
|
58 | + $this->assertEquals('Text field', $parameters['textfield']->getText()); |
|
59 | + $this->assertEquals(DefinitionParameter::VALUE_TEXT, $parameters['textfield']->getType()); |
|
60 | + $this->assertEquals(DefinitionParameter::FLAG_NONE, $parameters['textfield']->getFlags()); |
|
61 | + $this->assertEquals('Password field', $parameters['passwordfield']->getText()); |
|
62 | + $this->assertEquals(DefinitionParameter::VALUE_PASSWORD, $parameters['passwordfield']->getType()); |
|
63 | + $this->assertEquals(DefinitionParameter::FLAG_NONE, $parameters['passwordfield']->getFlags()); |
|
64 | + $this->assertEquals('Checkbox', $parameters['checkbox']->getText()); |
|
65 | + $this->assertEquals(DefinitionParameter::VALUE_BOOLEAN, $parameters['checkbox']->getType()); |
|
66 | + $this->assertEquals(DefinitionParameter::FLAG_NONE, $parameters['checkbox']->getFlags()); |
|
67 | + $this->assertEquals('Optional text field', $parameters['optionaltext']->getText()); |
|
68 | + $this->assertEquals(DefinitionParameter::VALUE_TEXT, $parameters['optionaltext']->getType()); |
|
69 | + $this->assertEquals(DefinitionParameter::FLAG_OPTIONAL, $parameters['optionaltext']->getFlags()); |
|
70 | + $this->assertEquals('Optional password field', $parameters['optionalpassword']->getText()); |
|
71 | + $this->assertEquals(DefinitionParameter::VALUE_PASSWORD, $parameters['optionalpassword']->getType()); |
|
72 | + $this->assertEquals(DefinitionParameter::FLAG_OPTIONAL, $parameters['optionalpassword']->getFlags()); |
|
73 | + } |
|
74 | 74 | |
75 | - public function testNoDependencies(): void { |
|
76 | - $auth = $this->createMock(Builtin::class); |
|
75 | + public function testNoDependencies(): void { |
|
76 | + $auth = $this->createMock(Builtin::class); |
|
77 | 77 | |
78 | - $class = self::class; |
|
79 | - $definition = [ |
|
80 | - 'configuration' => [ |
|
81 | - ], |
|
82 | - 'backend' => 'Backend text', |
|
83 | - ]; |
|
78 | + $class = self::class; |
|
79 | + $definition = [ |
|
80 | + 'configuration' => [ |
|
81 | + ], |
|
82 | + 'backend' => 'Backend text', |
|
83 | + ]; |
|
84 | 84 | |
85 | - $backend = new LegacyBackend($class, $definition, $auth); |
|
85 | + $backend = new LegacyBackend($class, $definition, $auth); |
|
86 | 86 | |
87 | - $dependencies = $backend->checkDependencies(); |
|
88 | - $this->assertCount(0, $dependencies); |
|
89 | - } |
|
87 | + $dependencies = $backend->checkDependencies(); |
|
88 | + $this->assertCount(0, $dependencies); |
|
89 | + } |
|
90 | 90 | } |
@@ -22,134 +22,134 @@ |
||
22 | 22 | * @group DB |
23 | 23 | */ |
24 | 24 | class StorePasswordListenerTest extends TestCase { |
25 | - protected IUser&MockObject $mockedUser; |
|
26 | - |
|
27 | - protected function setUp(): void { |
|
28 | - parent::setUp(); |
|
29 | - $this->mockedUser = $this->createMock(IUser::class); |
|
30 | - $this->mockedUser->method('getUID') |
|
31 | - ->willReturn('test'); |
|
32 | - } |
|
33 | - |
|
34 | - /** |
|
35 | - * @param array|false|null $initialCredentials |
|
36 | - * @param UserLoggedInEvent|PasswordUpdatedEvent $event |
|
37 | - * @param array|null $expectedCredentials |
|
38 | - */ |
|
39 | - public function getMockedCredentialManager($initialCredentials, $event, $expectedCredentials) { |
|
40 | - $mockedCredentialsManager = $this->createMock(ICredentialsManager::class); |
|
41 | - |
|
42 | - if ($initialCredentials !== null) { |
|
43 | - $mockedCredentialsManager |
|
44 | - ->expects($this->once()) |
|
45 | - ->method('retrieve') |
|
46 | - ->with( |
|
47 | - $this->equalTo('test'), |
|
48 | - $this->equalTo(LoginCredentials::CREDENTIALS_IDENTIFIER), |
|
49 | - ) |
|
50 | - ->willReturn($initialCredentials); |
|
51 | - } else { |
|
52 | - $mockedCredentialsManager |
|
53 | - ->expects($this->never()) |
|
54 | - ->method('retrieve'); |
|
55 | - } |
|
56 | - |
|
57 | - if ($expectedCredentials !== null) { |
|
58 | - $mockedCredentialsManager |
|
59 | - ->expects($this->once()) |
|
60 | - ->method('store') |
|
61 | - ->with( |
|
62 | - $this->equalTo('test'), |
|
63 | - $this->equalTo(LoginCredentials::CREDENTIALS_IDENTIFIER), |
|
64 | - $this->equalTo($expectedCredentials), |
|
65 | - ); |
|
66 | - } else { |
|
67 | - $mockedCredentialsManager |
|
68 | - ->expects($this->never()) |
|
69 | - ->method('store'); |
|
70 | - } |
|
71 | - |
|
72 | - $storePasswordListener = new StorePasswordListener($mockedCredentialsManager); |
|
73 | - $storePasswordListener->handle($event); |
|
74 | - } |
|
75 | - |
|
76 | - public function testClassicLoginSameCredentials(): void { |
|
77 | - $this->getMockedCredentialManager( |
|
78 | - [ |
|
79 | - 'user' => 'test', |
|
80 | - 'password' => 'password', |
|
81 | - ], |
|
82 | - new UserLoggedInEvent($this->mockedUser, 'test', 'password', false), |
|
83 | - null, |
|
84 | - ); |
|
85 | - } |
|
86 | - |
|
87 | - public function testClassicLoginNewPassword(): void { |
|
88 | - $this->getMockedCredentialManager( |
|
89 | - [ |
|
90 | - 'user' => 'test', |
|
91 | - 'password' => 'password', |
|
92 | - ], |
|
93 | - new UserLoggedInEvent($this->mockedUser, 'test', 'password2', false), |
|
94 | - [ |
|
95 | - 'user' => 'test', |
|
96 | - 'password' => 'password2', |
|
97 | - ], |
|
98 | - ); |
|
99 | - } |
|
100 | - |
|
101 | - public function testClassicLoginNewUser(): void { |
|
102 | - $this->getMockedCredentialManager( |
|
103 | - [ |
|
104 | - 'user' => 'test', |
|
105 | - 'password' => 'password', |
|
106 | - ], |
|
107 | - new UserLoggedInEvent($this->mockedUser, 'test2', 'password', false), |
|
108 | - [ |
|
109 | - 'user' => 'test2', |
|
110 | - 'password' => 'password', |
|
111 | - ], |
|
112 | - ); |
|
113 | - } |
|
114 | - |
|
115 | - public function testSSOLogin(): void { |
|
116 | - $this->getMockedCredentialManager( |
|
117 | - [ |
|
118 | - 'user' => 'test', |
|
119 | - 'password' => 'password', |
|
120 | - ], |
|
121 | - new UserLoggedInEvent($this->mockedUser, 'test', null, false), |
|
122 | - null, |
|
123 | - ); |
|
124 | - } |
|
125 | - |
|
126 | - public function testPasswordUpdated(): void { |
|
127 | - $this->getMockedCredentialManager( |
|
128 | - [ |
|
129 | - 'user' => 'test', |
|
130 | - 'password' => 'password', |
|
131 | - ], |
|
132 | - new PasswordUpdatedEvent($this->mockedUser, 'password2'), |
|
133 | - [ |
|
134 | - 'user' => 'test', |
|
135 | - 'password' => 'password2', |
|
136 | - ], |
|
137 | - ); |
|
138 | - } |
|
139 | - |
|
140 | - public function testUserLoginWithToken(): void { |
|
141 | - $this->getMockedCredentialManager( |
|
142 | - null, |
|
143 | - new UserLoggedInEvent($this->mockedUser, 'test', 'password', true), |
|
144 | - null, |
|
145 | - ); |
|
146 | - } |
|
147 | - |
|
148 | - public function testNoInitialCredentials(): void { |
|
149 | - $this->getMockedCredentialManager( |
|
150 | - false, |
|
151 | - new PasswordUpdatedEvent($this->mockedUser, 'test', 'password'), |
|
152 | - null, |
|
153 | - ); |
|
154 | - } |
|
25 | + protected IUser&MockObject $mockedUser; |
|
26 | + |
|
27 | + protected function setUp(): void { |
|
28 | + parent::setUp(); |
|
29 | + $this->mockedUser = $this->createMock(IUser::class); |
|
30 | + $this->mockedUser->method('getUID') |
|
31 | + ->willReturn('test'); |
|
32 | + } |
|
33 | + |
|
34 | + /** |
|
35 | + * @param array|false|null $initialCredentials |
|
36 | + * @param UserLoggedInEvent|PasswordUpdatedEvent $event |
|
37 | + * @param array|null $expectedCredentials |
|
38 | + */ |
|
39 | + public function getMockedCredentialManager($initialCredentials, $event, $expectedCredentials) { |
|
40 | + $mockedCredentialsManager = $this->createMock(ICredentialsManager::class); |
|
41 | + |
|
42 | + if ($initialCredentials !== null) { |
|
43 | + $mockedCredentialsManager |
|
44 | + ->expects($this->once()) |
|
45 | + ->method('retrieve') |
|
46 | + ->with( |
|
47 | + $this->equalTo('test'), |
|
48 | + $this->equalTo(LoginCredentials::CREDENTIALS_IDENTIFIER), |
|
49 | + ) |
|
50 | + ->willReturn($initialCredentials); |
|
51 | + } else { |
|
52 | + $mockedCredentialsManager |
|
53 | + ->expects($this->never()) |
|
54 | + ->method('retrieve'); |
|
55 | + } |
|
56 | + |
|
57 | + if ($expectedCredentials !== null) { |
|
58 | + $mockedCredentialsManager |
|
59 | + ->expects($this->once()) |
|
60 | + ->method('store') |
|
61 | + ->with( |
|
62 | + $this->equalTo('test'), |
|
63 | + $this->equalTo(LoginCredentials::CREDENTIALS_IDENTIFIER), |
|
64 | + $this->equalTo($expectedCredentials), |
|
65 | + ); |
|
66 | + } else { |
|
67 | + $mockedCredentialsManager |
|
68 | + ->expects($this->never()) |
|
69 | + ->method('store'); |
|
70 | + } |
|
71 | + |
|
72 | + $storePasswordListener = new StorePasswordListener($mockedCredentialsManager); |
|
73 | + $storePasswordListener->handle($event); |
|
74 | + } |
|
75 | + |
|
76 | + public function testClassicLoginSameCredentials(): void { |
|
77 | + $this->getMockedCredentialManager( |
|
78 | + [ |
|
79 | + 'user' => 'test', |
|
80 | + 'password' => 'password', |
|
81 | + ], |
|
82 | + new UserLoggedInEvent($this->mockedUser, 'test', 'password', false), |
|
83 | + null, |
|
84 | + ); |
|
85 | + } |
|
86 | + |
|
87 | + public function testClassicLoginNewPassword(): void { |
|
88 | + $this->getMockedCredentialManager( |
|
89 | + [ |
|
90 | + 'user' => 'test', |
|
91 | + 'password' => 'password', |
|
92 | + ], |
|
93 | + new UserLoggedInEvent($this->mockedUser, 'test', 'password2', false), |
|
94 | + [ |
|
95 | + 'user' => 'test', |
|
96 | + 'password' => 'password2', |
|
97 | + ], |
|
98 | + ); |
|
99 | + } |
|
100 | + |
|
101 | + public function testClassicLoginNewUser(): void { |
|
102 | + $this->getMockedCredentialManager( |
|
103 | + [ |
|
104 | + 'user' => 'test', |
|
105 | + 'password' => 'password', |
|
106 | + ], |
|
107 | + new UserLoggedInEvent($this->mockedUser, 'test2', 'password', false), |
|
108 | + [ |
|
109 | + 'user' => 'test2', |
|
110 | + 'password' => 'password', |
|
111 | + ], |
|
112 | + ); |
|
113 | + } |
|
114 | + |
|
115 | + public function testSSOLogin(): void { |
|
116 | + $this->getMockedCredentialManager( |
|
117 | + [ |
|
118 | + 'user' => 'test', |
|
119 | + 'password' => 'password', |
|
120 | + ], |
|
121 | + new UserLoggedInEvent($this->mockedUser, 'test', null, false), |
|
122 | + null, |
|
123 | + ); |
|
124 | + } |
|
125 | + |
|
126 | + public function testPasswordUpdated(): void { |
|
127 | + $this->getMockedCredentialManager( |
|
128 | + [ |
|
129 | + 'user' => 'test', |
|
130 | + 'password' => 'password', |
|
131 | + ], |
|
132 | + new PasswordUpdatedEvent($this->mockedUser, 'password2'), |
|
133 | + [ |
|
134 | + 'user' => 'test', |
|
135 | + 'password' => 'password2', |
|
136 | + ], |
|
137 | + ); |
|
138 | + } |
|
139 | + |
|
140 | + public function testUserLoginWithToken(): void { |
|
141 | + $this->getMockedCredentialManager( |
|
142 | + null, |
|
143 | + new UserLoggedInEvent($this->mockedUser, 'test', 'password', true), |
|
144 | + null, |
|
145 | + ); |
|
146 | + } |
|
147 | + |
|
148 | + public function testNoInitialCredentials(): void { |
|
149 | + $this->getMockedCredentialManager( |
|
150 | + false, |
|
151 | + new PasswordUpdatedEvent($this->mockedUser, 'test', 'password'), |
|
152 | + null, |
|
153 | + ); |
|
154 | + } |
|
155 | 155 | } |
@@ -18,82 +18,82 @@ |
||
18 | 18 | * @package OCA\Files_External\Tests |
19 | 19 | */ |
20 | 20 | class OwnCloudFunctionsTest extends \Test\TestCase { |
21 | - public static function configUrlProvider(): array { |
|
22 | - return [ |
|
23 | - [ |
|
24 | - [ |
|
25 | - 'host' => 'testhost', |
|
26 | - 'root' => 'testroot', |
|
27 | - 'secure' => false |
|
28 | - ], |
|
29 | - 'http://testhost/remote.php/webdav/testroot/', |
|
30 | - ], |
|
31 | - [ |
|
32 | - [ |
|
33 | - 'host' => 'testhost', |
|
34 | - 'root' => 'testroot', |
|
35 | - 'secure' => true |
|
36 | - ], |
|
37 | - 'https://testhost/remote.php/webdav/testroot/', |
|
38 | - ], |
|
39 | - [ |
|
40 | - [ |
|
41 | - 'host' => 'http://testhost', |
|
42 | - 'root' => 'testroot', |
|
43 | - 'secure' => false |
|
44 | - ], |
|
45 | - 'http://testhost/remote.php/webdav/testroot/', |
|
46 | - ], |
|
47 | - [ |
|
48 | - [ |
|
49 | - 'host' => 'https://testhost', |
|
50 | - 'root' => 'testroot', |
|
51 | - 'secure' => false |
|
52 | - ], |
|
53 | - 'https://testhost/remote.php/webdav/testroot/', |
|
54 | - ], |
|
55 | - [ |
|
56 | - [ |
|
57 | - 'host' => 'https://testhost/testroot', |
|
58 | - 'root' => '', |
|
59 | - 'secure' => false |
|
60 | - ], |
|
61 | - 'https://testhost/testroot/remote.php/webdav/', |
|
62 | - ], |
|
63 | - [ |
|
64 | - [ |
|
65 | - 'host' => 'https://testhost/testroot', |
|
66 | - 'root' => 'subdir', |
|
67 | - 'secure' => false |
|
68 | - ], |
|
69 | - 'https://testhost/testroot/remote.php/webdav/subdir/', |
|
70 | - ], |
|
71 | - [ |
|
72 | - [ |
|
73 | - 'host' => 'http://testhost/testroot', |
|
74 | - 'root' => 'subdir', |
|
75 | - 'secure' => true |
|
76 | - ], |
|
77 | - 'http://testhost/testroot/remote.php/webdav/subdir/', |
|
78 | - ], |
|
79 | - [ |
|
80 | - [ |
|
81 | - 'host' => 'http://testhost/testroot/', |
|
82 | - 'root' => '/subdir', |
|
83 | - 'secure' => false |
|
84 | - ], |
|
85 | - 'http://testhost/testroot/remote.php/webdav/subdir/', |
|
86 | - ], |
|
87 | - ]; |
|
88 | - } |
|
21 | + public static function configUrlProvider(): array { |
|
22 | + return [ |
|
23 | + [ |
|
24 | + [ |
|
25 | + 'host' => 'testhost', |
|
26 | + 'root' => 'testroot', |
|
27 | + 'secure' => false |
|
28 | + ], |
|
29 | + 'http://testhost/remote.php/webdav/testroot/', |
|
30 | + ], |
|
31 | + [ |
|
32 | + [ |
|
33 | + 'host' => 'testhost', |
|
34 | + 'root' => 'testroot', |
|
35 | + 'secure' => true |
|
36 | + ], |
|
37 | + 'https://testhost/remote.php/webdav/testroot/', |
|
38 | + ], |
|
39 | + [ |
|
40 | + [ |
|
41 | + 'host' => 'http://testhost', |
|
42 | + 'root' => 'testroot', |
|
43 | + 'secure' => false |
|
44 | + ], |
|
45 | + 'http://testhost/remote.php/webdav/testroot/', |
|
46 | + ], |
|
47 | + [ |
|
48 | + [ |
|
49 | + 'host' => 'https://testhost', |
|
50 | + 'root' => 'testroot', |
|
51 | + 'secure' => false |
|
52 | + ], |
|
53 | + 'https://testhost/remote.php/webdav/testroot/', |
|
54 | + ], |
|
55 | + [ |
|
56 | + [ |
|
57 | + 'host' => 'https://testhost/testroot', |
|
58 | + 'root' => '', |
|
59 | + 'secure' => false |
|
60 | + ], |
|
61 | + 'https://testhost/testroot/remote.php/webdav/', |
|
62 | + ], |
|
63 | + [ |
|
64 | + [ |
|
65 | + 'host' => 'https://testhost/testroot', |
|
66 | + 'root' => 'subdir', |
|
67 | + 'secure' => false |
|
68 | + ], |
|
69 | + 'https://testhost/testroot/remote.php/webdav/subdir/', |
|
70 | + ], |
|
71 | + [ |
|
72 | + [ |
|
73 | + 'host' => 'http://testhost/testroot', |
|
74 | + 'root' => 'subdir', |
|
75 | + 'secure' => true |
|
76 | + ], |
|
77 | + 'http://testhost/testroot/remote.php/webdav/subdir/', |
|
78 | + ], |
|
79 | + [ |
|
80 | + [ |
|
81 | + 'host' => 'http://testhost/testroot/', |
|
82 | + 'root' => '/subdir', |
|
83 | + 'secure' => false |
|
84 | + ], |
|
85 | + 'http://testhost/testroot/remote.php/webdav/subdir/', |
|
86 | + ], |
|
87 | + ]; |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * @dataProvider configUrlProvider |
|
92 | - */ |
|
93 | - public function testConfig(array $config, string $expectedUri): void { |
|
94 | - $config['user'] = 'someuser'; |
|
95 | - $config['password'] = 'somepassword'; |
|
96 | - $instance = new OwnCloud($config); |
|
97 | - $this->assertEquals($expectedUri, $instance->createBaseUri()); |
|
98 | - } |
|
90 | + /** |
|
91 | + * @dataProvider configUrlProvider |
|
92 | + */ |
|
93 | + public function testConfig(array $config, string $expectedUri): void { |
|
94 | + $config['user'] = 'someuser'; |
|
95 | + $config['password'] = 'somepassword'; |
|
96 | + $instance = new OwnCloud($config); |
|
97 | + $this->assertEquals($expectedUri, $instance->createBaseUri()); |
|
98 | + } |
|
99 | 99 | } |
@@ -11,74 +11,74 @@ |
||
11 | 11 | use OCA\Files_External\Lib\DefinitionParameter as Param; |
12 | 12 | |
13 | 13 | class DefinitionParameterTest extends \Test\TestCase { |
14 | - public function testJsonSerialization(): void { |
|
15 | - $param = new Param('foo', 'bar'); |
|
16 | - $this->assertEquals([ |
|
17 | - 'value' => 'bar', |
|
18 | - 'flags' => 0, |
|
19 | - 'type' => 0, |
|
20 | - 'tooltip' => '', |
|
21 | - ], $param->jsonSerialize()); |
|
14 | + public function testJsonSerialization(): void { |
|
15 | + $param = new Param('foo', 'bar'); |
|
16 | + $this->assertEquals([ |
|
17 | + 'value' => 'bar', |
|
18 | + 'flags' => 0, |
|
19 | + 'type' => 0, |
|
20 | + 'tooltip' => '', |
|
21 | + ], $param->jsonSerialize()); |
|
22 | 22 | |
23 | - $param->setType(Param::VALUE_BOOLEAN); |
|
24 | - $param->setDefaultValue(true); |
|
25 | - $this->assertEquals([ |
|
26 | - 'value' => 'bar', |
|
27 | - 'flags' => 0, |
|
28 | - 'type' => Param::VALUE_BOOLEAN, |
|
29 | - 'tooltip' => '', |
|
30 | - 'defaultValue' => true, |
|
31 | - ], $param->jsonSerialize()); |
|
23 | + $param->setType(Param::VALUE_BOOLEAN); |
|
24 | + $param->setDefaultValue(true); |
|
25 | + $this->assertEquals([ |
|
26 | + 'value' => 'bar', |
|
27 | + 'flags' => 0, |
|
28 | + 'type' => Param::VALUE_BOOLEAN, |
|
29 | + 'tooltip' => '', |
|
30 | + 'defaultValue' => true, |
|
31 | + ], $param->jsonSerialize()); |
|
32 | 32 | |
33 | - $param->setType(Param::VALUE_PASSWORD); |
|
34 | - $param->setFlag(Param::FLAG_OPTIONAL); |
|
35 | - $param->setDefaultValue(null); |
|
36 | - $this->assertEquals([ |
|
37 | - 'value' => 'bar', |
|
38 | - 'flags' => Param::FLAG_OPTIONAL, |
|
39 | - 'type' => Param::VALUE_PASSWORD, |
|
40 | - 'tooltip' => '', |
|
41 | - ], $param->jsonSerialize()); |
|
33 | + $param->setType(Param::VALUE_PASSWORD); |
|
34 | + $param->setFlag(Param::FLAG_OPTIONAL); |
|
35 | + $param->setDefaultValue(null); |
|
36 | + $this->assertEquals([ |
|
37 | + 'value' => 'bar', |
|
38 | + 'flags' => Param::FLAG_OPTIONAL, |
|
39 | + 'type' => Param::VALUE_PASSWORD, |
|
40 | + 'tooltip' => '', |
|
41 | + ], $param->jsonSerialize()); |
|
42 | 42 | |
43 | - $param->setType(Param::VALUE_TEXT); |
|
44 | - $param->setFlags(Param::FLAG_HIDDEN); |
|
45 | - $this->assertEquals([ |
|
46 | - 'value' => 'bar', |
|
47 | - 'flags' => Param::FLAG_HIDDEN, |
|
48 | - 'type' => Param::VALUE_TEXT, |
|
49 | - 'tooltip' => '', |
|
50 | - ], $param->jsonSerialize()); |
|
51 | - } |
|
43 | + $param->setType(Param::VALUE_TEXT); |
|
44 | + $param->setFlags(Param::FLAG_HIDDEN); |
|
45 | + $this->assertEquals([ |
|
46 | + 'value' => 'bar', |
|
47 | + 'flags' => Param::FLAG_HIDDEN, |
|
48 | + 'type' => Param::VALUE_TEXT, |
|
49 | + 'tooltip' => '', |
|
50 | + ], $param->jsonSerialize()); |
|
51 | + } |
|
52 | 52 | |
53 | - public static function validateValueProvider(): array { |
|
54 | - return [ |
|
55 | - [Param::VALUE_TEXT, Param::FLAG_NONE, 'abc', true], |
|
56 | - [Param::VALUE_TEXT, Param::FLAG_NONE, '', false], |
|
57 | - [Param::VALUE_TEXT, Param::FLAG_OPTIONAL, '', true], |
|
58 | - [Param::VALUE_TEXT, Param::FLAG_HIDDEN, '', false], |
|
53 | + public static function validateValueProvider(): array { |
|
54 | + return [ |
|
55 | + [Param::VALUE_TEXT, Param::FLAG_NONE, 'abc', true], |
|
56 | + [Param::VALUE_TEXT, Param::FLAG_NONE, '', false], |
|
57 | + [Param::VALUE_TEXT, Param::FLAG_OPTIONAL, '', true], |
|
58 | + [Param::VALUE_TEXT, Param::FLAG_HIDDEN, '', false], |
|
59 | 59 | |
60 | - [Param::VALUE_BOOLEAN, Param::FLAG_NONE, false, true], |
|
61 | - [Param::VALUE_BOOLEAN, Param::FLAG_NONE, 123, false], |
|
62 | - // conversion from string to boolean |
|
63 | - [Param::VALUE_BOOLEAN, Param::FLAG_NONE, 'false', true, false], |
|
64 | - [Param::VALUE_BOOLEAN, Param::FLAG_NONE, 'true', true, true], |
|
60 | + [Param::VALUE_BOOLEAN, Param::FLAG_NONE, false, true], |
|
61 | + [Param::VALUE_BOOLEAN, Param::FLAG_NONE, 123, false], |
|
62 | + // conversion from string to boolean |
|
63 | + [Param::VALUE_BOOLEAN, Param::FLAG_NONE, 'false', true, false], |
|
64 | + [Param::VALUE_BOOLEAN, Param::FLAG_NONE, 'true', true, true], |
|
65 | 65 | |
66 | - [Param::VALUE_PASSWORD, Param::FLAG_NONE, 'foobar', true], |
|
67 | - [Param::VALUE_PASSWORD, Param::FLAG_NONE, '', false], |
|
68 | - ]; |
|
69 | - } |
|
66 | + [Param::VALUE_PASSWORD, Param::FLAG_NONE, 'foobar', true], |
|
67 | + [Param::VALUE_PASSWORD, Param::FLAG_NONE, '', false], |
|
68 | + ]; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * @dataProvider validateValueProvider |
|
73 | - */ |
|
74 | - public function testValidateValue($type, $flags, $value, $success, $expectedValue = null): void { |
|
75 | - $param = new Param('foo', 'bar'); |
|
76 | - $param->setType($type); |
|
77 | - $param->setFlags($flags); |
|
71 | + /** |
|
72 | + * @dataProvider validateValueProvider |
|
73 | + */ |
|
74 | + public function testValidateValue($type, $flags, $value, $success, $expectedValue = null): void { |
|
75 | + $param = new Param('foo', 'bar'); |
|
76 | + $param->setType($type); |
|
77 | + $param->setFlags($flags); |
|
78 | 78 | |
79 | - $this->assertEquals($success, $param->validateValue($value)); |
|
80 | - if (isset($expectedValue)) { |
|
81 | - $this->assertEquals($expectedValue, $value); |
|
82 | - } |
|
83 | - } |
|
79 | + $this->assertEquals($success, $param->validateValue($value)); |
|
80 | + if (isset($expectedValue)) { |
|
81 | + $this->assertEquals($expectedValue, $value); |
|
82 | + } |
|
83 | + } |
|
84 | 84 | } |
@@ -12,27 +12,27 @@ |
||
12 | 12 | |
13 | 13 | class LegacyDependencyCheckPolyfillTest extends \Test\TestCase { |
14 | 14 | |
15 | - /** |
|
16 | - * @return MissingDependency[] |
|
17 | - */ |
|
18 | - public static function checkDependencies(): array { |
|
19 | - return [ |
|
20 | - (new MissingDependency('dependency'))->setMessage('missing dependency'), |
|
21 | - (new MissingDependency('program'))->setMessage('cannot find program'), |
|
22 | - ]; |
|
23 | - } |
|
15 | + /** |
|
16 | + * @return MissingDependency[] |
|
17 | + */ |
|
18 | + public static function checkDependencies(): array { |
|
19 | + return [ |
|
20 | + (new MissingDependency('dependency'))->setMessage('missing dependency'), |
|
21 | + (new MissingDependency('program'))->setMessage('cannot find program'), |
|
22 | + ]; |
|
23 | + } |
|
24 | 24 | |
25 | - public function testCheckDependencies(): void { |
|
26 | - $trait = $this->getMockForTrait(\OCA\Files_External\Lib\LegacyDependencyCheckPolyfill::class); |
|
27 | - $trait->expects($this->once()) |
|
28 | - ->method('getStorageClass') |
|
29 | - ->willReturn(self::class); |
|
25 | + public function testCheckDependencies(): void { |
|
26 | + $trait = $this->getMockForTrait(\OCA\Files_External\Lib\LegacyDependencyCheckPolyfill::class); |
|
27 | + $trait->expects($this->once()) |
|
28 | + ->method('getStorageClass') |
|
29 | + ->willReturn(self::class); |
|
30 | 30 | |
31 | - $dependencies = $trait->checkDependencies(); |
|
32 | - $this->assertCount(2, $dependencies); |
|
33 | - $this->assertEquals('dependency', $dependencies[0]->getDependency()); |
|
34 | - $this->assertEquals('missing dependency', $dependencies[0]->getMessage()); |
|
35 | - $this->assertEquals('program', $dependencies[1]->getDependency()); |
|
36 | - $this->assertEquals('cannot find program', $dependencies[1]->getMessage()); |
|
37 | - } |
|
31 | + $dependencies = $trait->checkDependencies(); |
|
32 | + $this->assertCount(2, $dependencies); |
|
33 | + $this->assertEquals('dependency', $dependencies[0]->getDependency()); |
|
34 | + $this->assertEquals('missing dependency', $dependencies[0]->getMessage()); |
|
35 | + $this->assertEquals('program', $dependencies[1]->getDependency()); |
|
36 | + $this->assertEquals('cannot find program', $dependencies[1]->getMessage()); |
|
37 | + } |
|
38 | 38 | } |