Completed
Push — master ( a96350...d0f819 )
by
unknown
29:59
created
tests/Core/Command/User/AuthTokens/DeleteTest.php 1 patch
Indentation   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -14,152 +14,152 @@
 block discarded – undo
14 14
 use Test\TestCase;
15 15
 
16 16
 class DeleteTest extends TestCase {
17
-	/** @var \PHPUnit\Framework\MockObject\MockObject */
18
-	protected $tokenProvider;
19
-	/** @var \PHPUnit\Framework\MockObject\MockObject */
20
-	protected $consoleInput;
21
-	/** @var \PHPUnit\Framework\MockObject\MockObject */
22
-	protected $consoleOutput;
23
-
24
-	/** @var \Symfony\Component\Console\Command\Command */
25
-	protected $command;
26
-
27
-	protected function setUp(): void {
28
-		parent::setUp();
29
-
30
-		$tokenProvider = $this->tokenProvider = $this->getMockBuilder(IProvider::class)
31
-			->disableOriginalConstructor()
32
-			->getMock();
33
-		$this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock();
34
-		$this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock();
35
-
36
-		/** @var \OC\Authentication\Token\IProvider $tokenProvider */
37
-		$this->command = new Delete($tokenProvider);
38
-	}
39
-
40
-	public function testDeleteTokenById(): void {
41
-		$this->consoleInput->expects($this->exactly(2))
42
-			->method('getArgument')
43
-			->willReturnMap([
44
-				['uid', 'user'],
45
-				['id', '42']
46
-			]);
47
-
48
-		$this->consoleInput->expects($this->once())
49
-			->method('getOption')
50
-			->with('last-used-before')
51
-			->willReturn(null);
52
-
53
-		$this->tokenProvider->expects($this->once())
54
-			->method('invalidateTokenById')
55
-			->with('user', 42);
56
-
57
-		$result = self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
58
-		$this->assertSame(Command::SUCCESS, $result);
59
-	}
60
-
61
-	public function testDeleteTokenByIdRequiresTokenId(): void {
62
-		$this->consoleInput->expects($this->exactly(2))
63
-			->method('getArgument')
64
-			->willReturnMap([
65
-				['uid', 'user'],
66
-				['id', null]
67
-			]);
68
-
69
-		$this->consoleInput->expects($this->once())
70
-			->method('getOption')
71
-			->with('last-used-before')
72
-			->willReturn(null);
73
-
74
-		$this->expectException(RuntimeException::class);
75
-
76
-		$this->tokenProvider->expects($this->never())->method('invalidateTokenById');
77
-
78
-		$result = self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
79
-		$this->assertSame(Command::FAILURE, $result);
80
-	}
81
-
82
-	public function testDeleteTokensLastUsedBefore(): void {
83
-		$this->consoleInput->expects($this->exactly(2))
84
-			->method('getArgument')
85
-			->willReturnMap([
86
-				['uid', 'user'],
87
-				['id', null]
88
-			]);
89
-
90
-		$this->consoleInput->expects($this->once())
91
-			->method('getOption')
92
-			->with('last-used-before')
93
-			->willReturn('946684800');
94
-
95
-		$this->tokenProvider->expects($this->once())
96
-			->method('invalidateLastUsedBefore')
97
-			->with('user', 946684800);
98
-
99
-		$result = self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
100
-		$this->assertSame(Command::SUCCESS, $result);
101
-	}
102
-
103
-	public function testLastUsedBeforeAcceptsIso8601Expanded(): void {
104
-		$this->consoleInput->expects($this->exactly(2))
105
-			->method('getArgument')
106
-			->willReturnMap([
107
-				['uid', 'user'],
108
-				['id', null]
109
-			]);
110
-
111
-		$this->consoleInput->expects($this->once())
112
-			->method('getOption')
113
-			->with('last-used-before')
114
-			->willReturn('2000-01-01T00:00:00Z');
115
-
116
-		$this->tokenProvider->expects($this->once())
117
-			->method('invalidateLastUsedBefore')
118
-			->with('user', 946684800);
119
-
120
-		$result = self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
121
-		$this->assertSame(Command::SUCCESS, $result);
122
-	}
123
-
124
-	public function testLastUsedBeforeAcceptsYmd(): void {
125
-		$this->consoleInput->expects($this->exactly(2))
126
-			->method('getArgument')
127
-			->willReturnMap([
128
-				['uid', 'user'],
129
-				['id', null]
130
-			]);
131
-
132
-		$this->consoleInput->expects($this->once())
133
-			->method('getOption')
134
-			->with('last-used-before')
135
-			->willReturn('2000-01-01');
136
-
137
-		$this->tokenProvider->expects($this->once())
138
-			->method('invalidateLastUsedBefore')
139
-			->with('user', 946684800);
140
-
141
-		$result = self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
142
-		$this->assertSame(Command::SUCCESS, $result);
143
-	}
144
-
145
-	public function testIdAndLastUsedBeforeAreMutuallyExclusive(): void {
146
-		$this->consoleInput->expects($this->exactly(2))
147
-			->method('getArgument')
148
-			->willReturnMap([
149
-				['uid', 'user'],
150
-				['id', '42']
151
-			]);
152
-
153
-		$this->consoleInput->expects($this->once())
154
-			->method('getOption')
155
-			->with('last-used-before')
156
-			->willReturn('946684800');
157
-
158
-		$this->expectException(RuntimeException::class);
159
-
160
-		$this->tokenProvider->expects($this->never())->method('invalidateLastUsedBefore');
161
-
162
-		$result = self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
163
-		$this->assertSame(Command::SUCCESS, $result);
164
-	}
17
+    /** @var \PHPUnit\Framework\MockObject\MockObject */
18
+    protected $tokenProvider;
19
+    /** @var \PHPUnit\Framework\MockObject\MockObject */
20
+    protected $consoleInput;
21
+    /** @var \PHPUnit\Framework\MockObject\MockObject */
22
+    protected $consoleOutput;
23
+
24
+    /** @var \Symfony\Component\Console\Command\Command */
25
+    protected $command;
26
+
27
+    protected function setUp(): void {
28
+        parent::setUp();
29
+
30
+        $tokenProvider = $this->tokenProvider = $this->getMockBuilder(IProvider::class)
31
+            ->disableOriginalConstructor()
32
+            ->getMock();
33
+        $this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock();
34
+        $this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock();
35
+
36
+        /** @var \OC\Authentication\Token\IProvider $tokenProvider */
37
+        $this->command = new Delete($tokenProvider);
38
+    }
39
+
40
+    public function testDeleteTokenById(): void {
41
+        $this->consoleInput->expects($this->exactly(2))
42
+            ->method('getArgument')
43
+            ->willReturnMap([
44
+                ['uid', 'user'],
45
+                ['id', '42']
46
+            ]);
47
+
48
+        $this->consoleInput->expects($this->once())
49
+            ->method('getOption')
50
+            ->with('last-used-before')
51
+            ->willReturn(null);
52
+
53
+        $this->tokenProvider->expects($this->once())
54
+            ->method('invalidateTokenById')
55
+            ->with('user', 42);
56
+
57
+        $result = self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
58
+        $this->assertSame(Command::SUCCESS, $result);
59
+    }
60
+
61
+    public function testDeleteTokenByIdRequiresTokenId(): void {
62
+        $this->consoleInput->expects($this->exactly(2))
63
+            ->method('getArgument')
64
+            ->willReturnMap([
65
+                ['uid', 'user'],
66
+                ['id', null]
67
+            ]);
68
+
69
+        $this->consoleInput->expects($this->once())
70
+            ->method('getOption')
71
+            ->with('last-used-before')
72
+            ->willReturn(null);
73
+
74
+        $this->expectException(RuntimeException::class);
75
+
76
+        $this->tokenProvider->expects($this->never())->method('invalidateTokenById');
77
+
78
+        $result = self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
79
+        $this->assertSame(Command::FAILURE, $result);
80
+    }
81
+
82
+    public function testDeleteTokensLastUsedBefore(): void {
83
+        $this->consoleInput->expects($this->exactly(2))
84
+            ->method('getArgument')
85
+            ->willReturnMap([
86
+                ['uid', 'user'],
87
+                ['id', null]
88
+            ]);
89
+
90
+        $this->consoleInput->expects($this->once())
91
+            ->method('getOption')
92
+            ->with('last-used-before')
93
+            ->willReturn('946684800');
94
+
95
+        $this->tokenProvider->expects($this->once())
96
+            ->method('invalidateLastUsedBefore')
97
+            ->with('user', 946684800);
98
+
99
+        $result = self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
100
+        $this->assertSame(Command::SUCCESS, $result);
101
+    }
102
+
103
+    public function testLastUsedBeforeAcceptsIso8601Expanded(): void {
104
+        $this->consoleInput->expects($this->exactly(2))
105
+            ->method('getArgument')
106
+            ->willReturnMap([
107
+                ['uid', 'user'],
108
+                ['id', null]
109
+            ]);
110
+
111
+        $this->consoleInput->expects($this->once())
112
+            ->method('getOption')
113
+            ->with('last-used-before')
114
+            ->willReturn('2000-01-01T00:00:00Z');
115
+
116
+        $this->tokenProvider->expects($this->once())
117
+            ->method('invalidateLastUsedBefore')
118
+            ->with('user', 946684800);
119
+
120
+        $result = self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
121
+        $this->assertSame(Command::SUCCESS, $result);
122
+    }
123
+
124
+    public function testLastUsedBeforeAcceptsYmd(): void {
125
+        $this->consoleInput->expects($this->exactly(2))
126
+            ->method('getArgument')
127
+            ->willReturnMap([
128
+                ['uid', 'user'],
129
+                ['id', null]
130
+            ]);
131
+
132
+        $this->consoleInput->expects($this->once())
133
+            ->method('getOption')
134
+            ->with('last-used-before')
135
+            ->willReturn('2000-01-01');
136
+
137
+        $this->tokenProvider->expects($this->once())
138
+            ->method('invalidateLastUsedBefore')
139
+            ->with('user', 946684800);
140
+
141
+        $result = self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
142
+        $this->assertSame(Command::SUCCESS, $result);
143
+    }
144
+
145
+    public function testIdAndLastUsedBeforeAreMutuallyExclusive(): void {
146
+        $this->consoleInput->expects($this->exactly(2))
147
+            ->method('getArgument')
148
+            ->willReturnMap([
149
+                ['uid', 'user'],
150
+                ['id', '42']
151
+            ]);
152
+
153
+        $this->consoleInput->expects($this->once())
154
+            ->method('getOption')
155
+            ->with('last-used-before')
156
+            ->willReturn('946684800');
157
+
158
+        $this->expectException(RuntimeException::class);
159
+
160
+        $this->tokenProvider->expects($this->never())->method('invalidateLastUsedBefore');
161
+
162
+        $result = self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
163
+        $this->assertSame(Command::SUCCESS, $result);
164
+    }
165 165
 }
Please login to merge, or discard this patch.
tests/Core/Command/User/DisableTest.php 1 patch
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -14,64 +14,64 @@
 block discarded – undo
14 14
 use Test\TestCase;
15 15
 
16 16
 class DisableTest extends TestCase {
17
-	/** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
18
-	protected $userManager;
19
-	/** @var InputInterface|\PHPUnit\Framework\MockObject\MockObject */
20
-	protected $consoleInput;
21
-	/** @var OutputInterface|\PHPUnit\Framework\MockObject\MockObject */
22
-	protected $consoleOutput;
23
-
24
-	/** @var Disable */
25
-	protected $command;
26
-
27
-	protected function setUp(): void {
28
-		parent::setUp();
29
-
30
-		$this->userManager = $this->createMock(IUserManager::class);
31
-		$this->consoleInput = $this->createMock(InputInterface::class);
32
-		$this->consoleOutput = $this->createMock(OutputInterface::class);
33
-
34
-		$this->command = new Disable($this->userManager);
35
-	}
36
-
37
-	public function testValidUser(): void {
38
-		$user = $this->createMock(IUser::class);
39
-		$user->expects($this->once())
40
-			->method('setEnabled')
41
-			->with(false);
42
-
43
-		$this->userManager
44
-			->method('get')
45
-			->with('user')
46
-			->willReturn($user);
47
-
48
-		$this->consoleInput
49
-			->method('getArgument')
50
-			->with('uid')
51
-			->willReturn('user');
52
-
53
-		$this->consoleOutput->expects($this->once())
54
-			->method('writeln')
55
-			->with($this->stringContains('The specified user is disabled'));
56
-
57
-		self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
58
-	}
59
-
60
-	public function testInvalidUser(): void {
61
-		$this->userManager->expects($this->once())
62
-			->method('get')
63
-			->with('user')
64
-			->willReturn(null);
65
-
66
-		$this->consoleInput
67
-			->method('getArgument')
68
-			->with('uid')
69
-			->willReturn('user');
70
-
71
-		$this->consoleOutput->expects($this->once())
72
-			->method('writeln')
73
-			->with($this->stringContains('User does not exist'));
74
-
75
-		self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
76
-	}
17
+    /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
18
+    protected $userManager;
19
+    /** @var InputInterface|\PHPUnit\Framework\MockObject\MockObject */
20
+    protected $consoleInput;
21
+    /** @var OutputInterface|\PHPUnit\Framework\MockObject\MockObject */
22
+    protected $consoleOutput;
23
+
24
+    /** @var Disable */
25
+    protected $command;
26
+
27
+    protected function setUp(): void {
28
+        parent::setUp();
29
+
30
+        $this->userManager = $this->createMock(IUserManager::class);
31
+        $this->consoleInput = $this->createMock(InputInterface::class);
32
+        $this->consoleOutput = $this->createMock(OutputInterface::class);
33
+
34
+        $this->command = new Disable($this->userManager);
35
+    }
36
+
37
+    public function testValidUser(): void {
38
+        $user = $this->createMock(IUser::class);
39
+        $user->expects($this->once())
40
+            ->method('setEnabled')
41
+            ->with(false);
42
+
43
+        $this->userManager
44
+            ->method('get')
45
+            ->with('user')
46
+            ->willReturn($user);
47
+
48
+        $this->consoleInput
49
+            ->method('getArgument')
50
+            ->with('uid')
51
+            ->willReturn('user');
52
+
53
+        $this->consoleOutput->expects($this->once())
54
+            ->method('writeln')
55
+            ->with($this->stringContains('The specified user is disabled'));
56
+
57
+        self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
58
+    }
59
+
60
+    public function testInvalidUser(): void {
61
+        $this->userManager->expects($this->once())
62
+            ->method('get')
63
+            ->with('user')
64
+            ->willReturn(null);
65
+
66
+        $this->consoleInput
67
+            ->method('getArgument')
68
+            ->with('uid')
69
+            ->willReturn('user');
70
+
71
+        $this->consoleOutput->expects($this->once())
72
+            ->method('writeln')
73
+            ->with($this->stringContains('User does not exist'));
74
+
75
+        self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
76
+    }
77 77
 }
Please login to merge, or discard this patch.
tests/Core/Command/Group/AddUserTest.php 1 patch
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -16,85 +16,85 @@
 block discarded – undo
16 16
 use Test\TestCase;
17 17
 
18 18
 class AddUserTest extends TestCase {
19
-	/** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */
20
-	private $groupManager;
21
-
22
-	/** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
23
-	private $userManager;
24
-
25
-	/** @var AddUser */
26
-	private $command;
27
-
28
-	/** @var InputInterface|\PHPUnit\Framework\MockObject\MockObject */
29
-	private $input;
30
-
31
-	/** @var OutputInterface|\PHPUnit\Framework\MockObject\MockObject */
32
-	private $output;
33
-
34
-	protected function setUp(): void {
35
-		parent::setUp();
36
-
37
-		$this->groupManager = $this->createMock(IGroupManager::class);
38
-		$this->userManager = $this->createMock(IUserManager::class);
39
-		$this->command = new AddUser($this->userManager, $this->groupManager);
40
-
41
-		$this->input = $this->createMock(InputInterface::class);
42
-		$this->input->method('getArgument')
43
-			->willReturnCallback(function ($arg) {
44
-				if ($arg === 'group') {
45
-					return 'myGroup';
46
-				} elseif ($arg === 'user') {
47
-					return 'myUser';
48
-				}
49
-				throw new \Exception();
50
-			});
51
-		$this->output = $this->createMock(OutputInterface::class);
52
-	}
53
-
54
-	public function testNoGroup(): void {
55
-		$this->groupManager->method('get')
56
-			->with('myGroup')
57
-			->willReturn(null);
58
-
59
-		$this->output->expects($this->once())
60
-			->method('writeln')
61
-			->with('<error>group not found</error>');
62
-
63
-		$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
64
-	}
65
-
66
-	public function testNoUser(): void {
67
-		$group = $this->createMock(IGroup::class);
68
-		$this->groupManager->method('get')
69
-			->with('myGroup')
70
-			->willReturn($group);
71
-
72
-		$this->userManager->method('get')
73
-			->with('myUser')
74
-			->willReturn(null);
75
-
76
-		$this->output->expects($this->once())
77
-			->method('writeln')
78
-			->with('<error>user not found</error>');
79
-
80
-		$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
81
-	}
82
-
83
-	public function testAdd(): void {
84
-		$group = $this->createMock(IGroup::class);
85
-		$this->groupManager->method('get')
86
-			->with('myGroup')
87
-			->willReturn($group);
88
-
89
-		$user = $this->createMock(IUser::class);
90
-		$this->userManager->method('get')
91
-			->with('myUser')
92
-			->willReturn($user);
93
-
94
-		$group->expects($this->once())
95
-			->method('addUser')
96
-			->with($user);
97
-
98
-		$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
99
-	}
19
+    /** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */
20
+    private $groupManager;
21
+
22
+    /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
23
+    private $userManager;
24
+
25
+    /** @var AddUser */
26
+    private $command;
27
+
28
+    /** @var InputInterface|\PHPUnit\Framework\MockObject\MockObject */
29
+    private $input;
30
+
31
+    /** @var OutputInterface|\PHPUnit\Framework\MockObject\MockObject */
32
+    private $output;
33
+
34
+    protected function setUp(): void {
35
+        parent::setUp();
36
+
37
+        $this->groupManager = $this->createMock(IGroupManager::class);
38
+        $this->userManager = $this->createMock(IUserManager::class);
39
+        $this->command = new AddUser($this->userManager, $this->groupManager);
40
+
41
+        $this->input = $this->createMock(InputInterface::class);
42
+        $this->input->method('getArgument')
43
+            ->willReturnCallback(function ($arg) {
44
+                if ($arg === 'group') {
45
+                    return 'myGroup';
46
+                } elseif ($arg === 'user') {
47
+                    return 'myUser';
48
+                }
49
+                throw new \Exception();
50
+            });
51
+        $this->output = $this->createMock(OutputInterface::class);
52
+    }
53
+
54
+    public function testNoGroup(): void {
55
+        $this->groupManager->method('get')
56
+            ->with('myGroup')
57
+            ->willReturn(null);
58
+
59
+        $this->output->expects($this->once())
60
+            ->method('writeln')
61
+            ->with('<error>group not found</error>');
62
+
63
+        $this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
64
+    }
65
+
66
+    public function testNoUser(): void {
67
+        $group = $this->createMock(IGroup::class);
68
+        $this->groupManager->method('get')
69
+            ->with('myGroup')
70
+            ->willReturn($group);
71
+
72
+        $this->userManager->method('get')
73
+            ->with('myUser')
74
+            ->willReturn(null);
75
+
76
+        $this->output->expects($this->once())
77
+            ->method('writeln')
78
+            ->with('<error>user not found</error>');
79
+
80
+        $this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
81
+    }
82
+
83
+    public function testAdd(): void {
84
+        $group = $this->createMock(IGroup::class);
85
+        $this->groupManager->method('get')
86
+            ->with('myGroup')
87
+            ->willReturn($group);
88
+
89
+        $user = $this->createMock(IUser::class);
90
+        $this->userManager->method('get')
91
+            ->with('myUser')
92
+            ->willReturn($user);
93
+
94
+        $group->expects($this->once())
95
+            ->method('addUser')
96
+            ->with($user);
97
+
98
+        $this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
99
+    }
100 100
 }
Please login to merge, or discard this patch.
tests/Core/Command/Group/RemoveUserTest.php 1 patch
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -16,85 +16,85 @@
 block discarded – undo
16 16
 use Test\TestCase;
17 17
 
18 18
 class RemoveUserTest extends TestCase {
19
-	/** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */
20
-	private $groupManager;
21
-
22
-	/** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
23
-	private $userManager;
24
-
25
-	/** @var RemoveUser */
26
-	private $command;
27
-
28
-	/** @var InputInterface|\PHPUnit\Framework\MockObject\MockObject */
29
-	private $input;
30
-
31
-	/** @var OutputInterface|\PHPUnit\Framework\MockObject\MockObject */
32
-	private $output;
33
-
34
-	protected function setUp(): void {
35
-		parent::setUp();
36
-
37
-		$this->groupManager = $this->createMock(IGroupManager::class);
38
-		$this->userManager = $this->createMock(IUserManager::class);
39
-		$this->command = new RemoveUser($this->userManager, $this->groupManager);
40
-
41
-		$this->input = $this->createMock(InputInterface::class);
42
-		$this->input->method('getArgument')
43
-			->willReturnCallback(function ($arg) {
44
-				if ($arg === 'group') {
45
-					return 'myGroup';
46
-				} elseif ($arg === 'user') {
47
-					return 'myUser';
48
-				}
49
-				throw new \Exception();
50
-			});
51
-		$this->output = $this->createMock(OutputInterface::class);
52
-	}
53
-
54
-	public function testNoGroup(): void {
55
-		$this->groupManager->method('get')
56
-			->with('myGroup')
57
-			->willReturn(null);
58
-
59
-		$this->output->expects($this->once())
60
-			->method('writeln')
61
-			->with('<error>group not found</error>');
62
-
63
-		$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
64
-	}
65
-
66
-	public function testNoUser(): void {
67
-		$group = $this->createMock(IGroup::class);
68
-		$this->groupManager->method('get')
69
-			->with('myGroup')
70
-			->willReturn($group);
71
-
72
-		$this->userManager->method('get')
73
-			->with('myUser')
74
-			->willReturn(null);
75
-
76
-		$this->output->expects($this->once())
77
-			->method('writeln')
78
-			->with('<error>user not found</error>');
79
-
80
-		$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
81
-	}
82
-
83
-	public function testAdd(): void {
84
-		$group = $this->createMock(IGroup::class);
85
-		$this->groupManager->method('get')
86
-			->with('myGroup')
87
-			->willReturn($group);
88
-
89
-		$user = $this->createMock(IUser::class);
90
-		$this->userManager->method('get')
91
-			->with('myUser')
92
-			->willReturn($user);
93
-
94
-		$group->expects($this->once())
95
-			->method('removeUser')
96
-			->with($user);
97
-
98
-		$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
99
-	}
19
+    /** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */
20
+    private $groupManager;
21
+
22
+    /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
23
+    private $userManager;
24
+
25
+    /** @var RemoveUser */
26
+    private $command;
27
+
28
+    /** @var InputInterface|\PHPUnit\Framework\MockObject\MockObject */
29
+    private $input;
30
+
31
+    /** @var OutputInterface|\PHPUnit\Framework\MockObject\MockObject */
32
+    private $output;
33
+
34
+    protected function setUp(): void {
35
+        parent::setUp();
36
+
37
+        $this->groupManager = $this->createMock(IGroupManager::class);
38
+        $this->userManager = $this->createMock(IUserManager::class);
39
+        $this->command = new RemoveUser($this->userManager, $this->groupManager);
40
+
41
+        $this->input = $this->createMock(InputInterface::class);
42
+        $this->input->method('getArgument')
43
+            ->willReturnCallback(function ($arg) {
44
+                if ($arg === 'group') {
45
+                    return 'myGroup';
46
+                } elseif ($arg === 'user') {
47
+                    return 'myUser';
48
+                }
49
+                throw new \Exception();
50
+            });
51
+        $this->output = $this->createMock(OutputInterface::class);
52
+    }
53
+
54
+    public function testNoGroup(): void {
55
+        $this->groupManager->method('get')
56
+            ->with('myGroup')
57
+            ->willReturn(null);
58
+
59
+        $this->output->expects($this->once())
60
+            ->method('writeln')
61
+            ->with('<error>group not found</error>');
62
+
63
+        $this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
64
+    }
65
+
66
+    public function testNoUser(): void {
67
+        $group = $this->createMock(IGroup::class);
68
+        $this->groupManager->method('get')
69
+            ->with('myGroup')
70
+            ->willReturn($group);
71
+
72
+        $this->userManager->method('get')
73
+            ->with('myUser')
74
+            ->willReturn(null);
75
+
76
+        $this->output->expects($this->once())
77
+            ->method('writeln')
78
+            ->with('<error>user not found</error>');
79
+
80
+        $this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
81
+    }
82
+
83
+    public function testAdd(): void {
84
+        $group = $this->createMock(IGroup::class);
85
+        $this->groupManager->method('get')
86
+            ->with('myGroup')
87
+            ->willReturn($group);
88
+
89
+        $user = $this->createMock(IUser::class);
90
+        $this->userManager->method('get')
91
+            ->with('myUser')
92
+            ->willReturn($user);
93
+
94
+        $group->expects($this->once())
95
+            ->method('removeUser')
96
+            ->with($user);
97
+
98
+        $this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
99
+    }
100 100
 }
Please login to merge, or discard this patch.
tests/Core/Command/Group/DeleteTest.php 1 patch
Indentation   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -14,118 +14,118 @@
 block discarded – undo
14 14
 use Test\TestCase;
15 15
 
16 16
 class DeleteTest extends TestCase {
17
-	/** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */
18
-	private $groupManager;
19
-
20
-	/** @var Delete */
21
-	private $command;
22
-
23
-	/** @var InputInterface|\PHPUnit\Framework\MockObject\MockObject */
24
-	private $input;
25
-
26
-	/** @var OutputInterface|\PHPUnit\Framework\MockObject\MockObject */
27
-	private $output;
28
-
29
-	protected function setUp(): void {
30
-		parent::setUp();
31
-
32
-		$this->groupManager = $this->createMock(IGroupManager::class);
33
-		$this->command = new Delete($this->groupManager);
34
-
35
-		$this->input = $this->createMock(InputInterface::class);
36
-		$this->output = $this->createMock(OutputInterface::class);
37
-	}
38
-
39
-	public function testDoesNotExists(): void {
40
-		$gid = 'myGroup';
41
-		$this->input->method('getArgument')
42
-			->willReturnCallback(function ($arg) use ($gid) {
43
-				if ($arg === 'groupid') {
44
-					return $gid;
45
-				}
46
-				throw new \Exception();
47
-			});
48
-		$this->groupManager->method('groupExists')
49
-			->with($gid)
50
-			->willReturn(false);
51
-
52
-		$this->groupManager->expects($this->never())
53
-			->method('get');
54
-		$this->output->expects($this->once())
55
-			->method('writeln')
56
-			->with($this->equalTo('<error>Group "' . $gid . '" does not exist.</error>'));
57
-
58
-		$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
59
-	}
60
-
61
-	public function testDeleteAdmin(): void {
62
-		$gid = 'admin';
63
-		$this->input->method('getArgument')
64
-			->willReturnCallback(function ($arg) use ($gid) {
65
-				if ($arg === 'groupid') {
66
-					return $gid;
67
-				}
68
-				throw new \Exception();
69
-			});
70
-
71
-		$this->groupManager->expects($this->never())
72
-			->method($this->anything());
73
-		$this->output->expects($this->once())
74
-			->method('writeln')
75
-			->with($this->equalTo('<error>Group "' . $gid . '" could not be deleted.</error>'));
76
-
77
-		$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
78
-	}
79
-
80
-	public function testDeleteFailed(): void {
81
-		$gid = 'myGroup';
82
-		$this->input->method('getArgument')
83
-			->willReturnCallback(function ($arg) use ($gid) {
84
-				if ($arg === 'groupid') {
85
-					return $gid;
86
-				}
87
-				throw new \Exception();
88
-			});
89
-		$group = $this->createMock(IGroup::class);
90
-		$group->method('delete')
91
-			->willReturn(false);
92
-		$this->groupManager->method('groupExists')
93
-			->with($gid)
94
-			->willReturn(true);
95
-		$this->groupManager->method('get')
96
-			->with($gid)
97
-			->willReturn($group);
98
-
99
-		$this->output->expects($this->once())
100
-			->method('writeln')
101
-			->with($this->equalTo('<error>Group "' . $gid . '" could not be deleted. Please check the logs.</error>'));
102
-
103
-		$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
104
-	}
105
-
106
-	public function testDelete(): void {
107
-		$gid = 'myGroup';
108
-		$this->input->method('getArgument')
109
-			->willReturnCallback(function ($arg) use ($gid) {
110
-				if ($arg === 'groupid') {
111
-					return $gid;
112
-				}
113
-				throw new \Exception();
114
-			});
115
-		$group = $this->createMock(IGroup::class);
116
-		$group->method('delete')
117
-			->willReturn(true);
118
-		$this->groupManager->method('groupExists')
119
-			->with($gid)
120
-			->willReturn(true);
121
-		$this->groupManager->method('get')
122
-			->with($gid)
123
-			->willReturn($group);
124
-
125
-		$this->output->expects($this->once())
126
-			->method('writeln')
127
-			->with($this->equalTo('Group "' . $gid . '" was removed'));
128
-
129
-		$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
130
-	}
17
+    /** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */
18
+    private $groupManager;
19
+
20
+    /** @var Delete */
21
+    private $command;
22
+
23
+    /** @var InputInterface|\PHPUnit\Framework\MockObject\MockObject */
24
+    private $input;
25
+
26
+    /** @var OutputInterface|\PHPUnit\Framework\MockObject\MockObject */
27
+    private $output;
28
+
29
+    protected function setUp(): void {
30
+        parent::setUp();
31
+
32
+        $this->groupManager = $this->createMock(IGroupManager::class);
33
+        $this->command = new Delete($this->groupManager);
34
+
35
+        $this->input = $this->createMock(InputInterface::class);
36
+        $this->output = $this->createMock(OutputInterface::class);
37
+    }
38
+
39
+    public function testDoesNotExists(): void {
40
+        $gid = 'myGroup';
41
+        $this->input->method('getArgument')
42
+            ->willReturnCallback(function ($arg) use ($gid) {
43
+                if ($arg === 'groupid') {
44
+                    return $gid;
45
+                }
46
+                throw new \Exception();
47
+            });
48
+        $this->groupManager->method('groupExists')
49
+            ->with($gid)
50
+            ->willReturn(false);
51
+
52
+        $this->groupManager->expects($this->never())
53
+            ->method('get');
54
+        $this->output->expects($this->once())
55
+            ->method('writeln')
56
+            ->with($this->equalTo('<error>Group "' . $gid . '" does not exist.</error>'));
57
+
58
+        $this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
59
+    }
60
+
61
+    public function testDeleteAdmin(): void {
62
+        $gid = 'admin';
63
+        $this->input->method('getArgument')
64
+            ->willReturnCallback(function ($arg) use ($gid) {
65
+                if ($arg === 'groupid') {
66
+                    return $gid;
67
+                }
68
+                throw new \Exception();
69
+            });
70
+
71
+        $this->groupManager->expects($this->never())
72
+            ->method($this->anything());
73
+        $this->output->expects($this->once())
74
+            ->method('writeln')
75
+            ->with($this->equalTo('<error>Group "' . $gid . '" could not be deleted.</error>'));
76
+
77
+        $this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
78
+    }
79
+
80
+    public function testDeleteFailed(): void {
81
+        $gid = 'myGroup';
82
+        $this->input->method('getArgument')
83
+            ->willReturnCallback(function ($arg) use ($gid) {
84
+                if ($arg === 'groupid') {
85
+                    return $gid;
86
+                }
87
+                throw new \Exception();
88
+            });
89
+        $group = $this->createMock(IGroup::class);
90
+        $group->method('delete')
91
+            ->willReturn(false);
92
+        $this->groupManager->method('groupExists')
93
+            ->with($gid)
94
+            ->willReturn(true);
95
+        $this->groupManager->method('get')
96
+            ->with($gid)
97
+            ->willReturn($group);
98
+
99
+        $this->output->expects($this->once())
100
+            ->method('writeln')
101
+            ->with($this->equalTo('<error>Group "' . $gid . '" could not be deleted. Please check the logs.</error>'));
102
+
103
+        $this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
104
+    }
105
+
106
+    public function testDelete(): void {
107
+        $gid = 'myGroup';
108
+        $this->input->method('getArgument')
109
+            ->willReturnCallback(function ($arg) use ($gid) {
110
+                if ($arg === 'groupid') {
111
+                    return $gid;
112
+                }
113
+                throw new \Exception();
114
+            });
115
+        $group = $this->createMock(IGroup::class);
116
+        $group->method('delete')
117
+            ->willReturn(true);
118
+        $this->groupManager->method('groupExists')
119
+            ->with($gid)
120
+            ->willReturn(true);
121
+        $this->groupManager->method('get')
122
+            ->with($gid)
123
+            ->willReturn($group);
124
+
125
+        $this->output->expects($this->once())
126
+            ->method('writeln')
127
+            ->with($this->equalTo('Group "' . $gid . '" was removed'));
128
+
129
+        $this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
130
+    }
131 131
 }
Please login to merge, or discard this patch.
tests/redis-cluster.config.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -4,20 +4,20 @@
 block discarded – undo
4 4
  * SPDX-License-Identifier: AGPL-3.0-or-later
5 5
  */
6 6
 $CONFIG = [
7
-	'memcache.local' => '\\OC\\Memcache\\Redis',
8
-	'memcache.distributed' => '\\OC\\Memcache\\Redis',
9
-	'memcache.locking' => '\\OC\\Memcache\\Redis',
10
-	'redis.cluster' => [
11
-		'seeds' => [ // provide some/all of the cluster servers to bootstrap discovery, port required
12
-			'cache-cluster:7000',
13
-			'cache-cluster:7001',
14
-			'cache-cluster:7002',
15
-			'cache-cluster:7003',
16
-			'cache-cluster:7004',
17
-			'cache-cluster:7005'
18
-		],
19
-		'timeout' => 0.0,
20
-		'read_timeout' => 0.0,
21
-		'failover_mode' => \RedisCluster::FAILOVER_ERROR
22
-	],
7
+    'memcache.local' => '\\OC\\Memcache\\Redis',
8
+    'memcache.distributed' => '\\OC\\Memcache\\Redis',
9
+    'memcache.locking' => '\\OC\\Memcache\\Redis',
10
+    'redis.cluster' => [
11
+        'seeds' => [ // provide some/all of the cluster servers to bootstrap discovery, port required
12
+            'cache-cluster:7000',
13
+            'cache-cluster:7001',
14
+            'cache-cluster:7002',
15
+            'cache-cluster:7003',
16
+            'cache-cluster:7004',
17
+            'cache-cluster:7005'
18
+        ],
19
+        'timeout' => 0.0,
20
+        'read_timeout' => 0.0,
21
+        'failover_mode' => \RedisCluster::FAILOVER_ERROR
22
+    ],
23 23
 ];
Please login to merge, or discard this patch.
tests/preseed-config.php 1 patch
Indentation   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -5,112 +5,112 @@
 block discarded – undo
5 5
  * SPDX-License-Identifier: AGPL-3.0-only
6 6
  */
7 7
 $CONFIG = [
8
-	'appstoreenabled' => false,
9
-	'apps_paths' => [
10
-		[
11
-			'path' => OC::$SERVERROOT . '/apps',
12
-			'url' => '/apps',
13
-			'writable' => true,
14
-		],
15
-	],
8
+    'appstoreenabled' => false,
9
+    'apps_paths' => [
10
+        [
11
+            'path' => OC::$SERVERROOT . '/apps',
12
+            'url' => '/apps',
13
+            'writable' => true,
14
+        ],
15
+    ],
16 16
 ];
17 17
 
18 18
 if (is_dir(OC::$SERVERROOT . '/apps2')) {
19
-	$CONFIG['apps_paths'][] = [
20
-		'path' => OC::$SERVERROOT . '/apps2',
21
-		'url' => '/apps2',
22
-		'writable' => false,
23
-	];
19
+    $CONFIG['apps_paths'][] = [
20
+        'path' => OC::$SERVERROOT . '/apps2',
21
+        'url' => '/apps2',
22
+        'writable' => false,
23
+    ];
24 24
 }
25 25
 
26 26
 if (getenv('OBJECT_STORE') === 's3') {
27
-	$CONFIG['objectstore'] = [
28
-		'class' => 'OC\\Files\\ObjectStore\\S3',
29
-		'arguments' => [
30
-			'bucket' => 'nextcloud',
31
-			'autocreate' => true,
32
-			'key' => getenv('OBJECT_STORE_KEY') ?: 'nextcloud',
33
-			'secret' => getenv('OBJECT_STORE_SECRET') ?: 'nextcloud',
34
-			'hostname' => getenv('OBJECT_STORE_HOST') ?: 'localhost',
35
-			'port' => 9000,
36
-			'use_ssl' => false,
37
-			// required for some non amazon s3 implementations
38
-			'use_path_style' => true
39
-		]
40
-	];
27
+    $CONFIG['objectstore'] = [
28
+        'class' => 'OC\\Files\\ObjectStore\\S3',
29
+        'arguments' => [
30
+            'bucket' => 'nextcloud',
31
+            'autocreate' => true,
32
+            'key' => getenv('OBJECT_STORE_KEY') ?: 'nextcloud',
33
+            'secret' => getenv('OBJECT_STORE_SECRET') ?: 'nextcloud',
34
+            'hostname' => getenv('OBJECT_STORE_HOST') ?: 'localhost',
35
+            'port' => 9000,
36
+            'use_ssl' => false,
37
+            // required for some non amazon s3 implementations
38
+            'use_path_style' => true
39
+        ]
40
+    ];
41 41
 } elseif (getenv('OBJECT_STORE') === 's3-multibucket') {
42
-	$CONFIG['objectstore_multibucket'] = [
43
-		'class' => 'OC\\Files\\ObjectStore\\S3',
44
-		'arguments' => [
45
-			'bucket' => 'nextcloud',
46
-			'autocreate' => true,
47
-			'key' => getenv('OBJECT_STORE_KEY') ?: 'nextcloud',
48
-			'secret' => getenv('OBJECT_STORE_SECRET') ?: 'nextcloud',
49
-			'hostname' => getenv('OBJECT_STORE_HOST') ?: 'localhost',
50
-			'port' => 9000,
51
-			'use_ssl' => false,
52
-			// required for some non amazon s3 implementations
53
-			'use_path_style' => true
54
-		]
55
-	];
42
+    $CONFIG['objectstore_multibucket'] = [
43
+        'class' => 'OC\\Files\\ObjectStore\\S3',
44
+        'arguments' => [
45
+            'bucket' => 'nextcloud',
46
+            'autocreate' => true,
47
+            'key' => getenv('OBJECT_STORE_KEY') ?: 'nextcloud',
48
+            'secret' => getenv('OBJECT_STORE_SECRET') ?: 'nextcloud',
49
+            'hostname' => getenv('OBJECT_STORE_HOST') ?: 'localhost',
50
+            'port' => 9000,
51
+            'use_ssl' => false,
52
+            // required for some non amazon s3 implementations
53
+            'use_path_style' => true
54
+        ]
55
+    ];
56 56
 } elseif (getenv('OBJECT_STORE') === 'azure') {
57
-	$CONFIG['objectstore'] = [
58
-		'class' => 'OC\\Files\\ObjectStore\\Azure',
59
-		'arguments' => [
60
-			'container' => 'test',
61
-			'account_name' => getenv('OBJECT_STORE_KEY') ?: 'devstoreaccount1',
62
-			'account_key' => getenv('OBJECT_STORE_SECRET') ?: 'Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==',
63
-			'endpoint' => 'http://' . (getenv('OBJECT_STORE_HOST') ?: 'localhost') . ':10000/' . (getenv('OBJECT_STORE_KEY') ?: 'devstoreaccount1'),
64
-			'autocreate' => true
65
-		]
66
-	];
57
+    $CONFIG['objectstore'] = [
58
+        'class' => 'OC\\Files\\ObjectStore\\Azure',
59
+        'arguments' => [
60
+            'container' => 'test',
61
+            'account_name' => getenv('OBJECT_STORE_KEY') ?: 'devstoreaccount1',
62
+            'account_key' => getenv('OBJECT_STORE_SECRET') ?: 'Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==',
63
+            'endpoint' => 'http://' . (getenv('OBJECT_STORE_HOST') ?: 'localhost') . ':10000/' . (getenv('OBJECT_STORE_KEY') ?: 'devstoreaccount1'),
64
+            'autocreate' => true
65
+        ]
66
+    ];
67 67
 } elseif (getenv('OBJECT_STORE') === 'swift') {
68
-	$swiftHost = getenv('OBJECT_STORE_HOST') ?: 'localhost:5000';
68
+    $swiftHost = getenv('OBJECT_STORE_HOST') ?: 'localhost:5000';
69 69
 
70
-	$CONFIG['objectstore'] = [
71
-		'class' => 'OC\\Files\\ObjectStore\\Swift',
72
-		'arguments' => [
73
-			'autocreate' => true,
74
-			'user' => [
75
-				'name' => getenv('OBJECT_STORE_KEY') ?: 'swift',
76
-				'password' => getenv('OBJECT_STORE_SECRET') ?: 'swift',
77
-				'domain' => [
78
-					'name' => 'Default',
79
-				],
80
-			],
81
-			'scope' => [
82
-				'project' => [
83
-					'name' => 'service',
84
-					'domain' => [
85
-						'name' => 'Default',
86
-					],
87
-				],
88
-			],
89
-			'serviceName' => 'service',
90
-			'region' => 'RegionOne',
91
-			'url' => "http://$swiftHost/v3",
92
-			'bucket' => 'nextcloud',
93
-		]
94
-	];
70
+    $CONFIG['objectstore'] = [
71
+        'class' => 'OC\\Files\\ObjectStore\\Swift',
72
+        'arguments' => [
73
+            'autocreate' => true,
74
+            'user' => [
75
+                'name' => getenv('OBJECT_STORE_KEY') ?: 'swift',
76
+                'password' => getenv('OBJECT_STORE_SECRET') ?: 'swift',
77
+                'domain' => [
78
+                    'name' => 'Default',
79
+                ],
80
+            ],
81
+            'scope' => [
82
+                'project' => [
83
+                    'name' => 'service',
84
+                    'domain' => [
85
+                        'name' => 'Default',
86
+                    ],
87
+                ],
88
+            ],
89
+            'serviceName' => 'service',
90
+            'region' => 'RegionOne',
91
+            'url' => "http://$swiftHost/v3",
92
+            'bucket' => 'nextcloud',
93
+        ]
94
+    ];
95 95
 }
96 96
 
97 97
 if (getenv('SHARDING') == '1') {
98
-	$CONFIG['dbsharding'] = [
99
-		'filecache' => [
100
-			'shards' => [
101
-				[
102
-					'port' => 5001,
103
-				],
104
-				[
105
-					'port' => 5002,
106
-				],
107
-				[
108
-					'port' => 5003,
109
-				],
110
-				[
111
-					'port' => 5004,
112
-				],
113
-			]
114
-		]
115
-	];
98
+    $CONFIG['dbsharding'] = [
99
+        'filecache' => [
100
+            'shards' => [
101
+                [
102
+                    'port' => 5001,
103
+                ],
104
+                [
105
+                    'port' => 5002,
106
+                ],
107
+                [
108
+                    'port' => 5003,
109
+                ],
110
+                [
111
+                    'port' => 5004,
112
+                ],
113
+            ]
114
+        ]
115
+    ];
116 116
 }
Please login to merge, or discard this patch.
tests/lib/Accounts/AccountPropertyCollectionTest.php 1 patch
Indentation   +172 added lines, -172 removed lines patch added patch discarded remove patch
@@ -17,176 +17,176 @@
 block discarded – undo
17 17
 use Test\TestCase;
18 18
 
19 19
 class AccountPropertyCollectionTest extends TestCase {
20
-	/** @var IAccountPropertyCollection */
21
-	protected $collection;
22
-
23
-	protected const COLLECTION_NAME = 'my_multivalue_property';
24
-
25
-	public function setUp(): void {
26
-		parent::setUp();
27
-
28
-		$this->collection = new AccountPropertyCollection(self::COLLECTION_NAME);
29
-	}
30
-
31
-	/**
32
-	 * @return IAccountProperty|MockObject
33
-	 */
34
-	protected function makePropertyMock(string $propertyName): MockObject {
35
-		$mock = $this->createMock(IAccountProperty::class);
36
-		$mock->expects($this->any())
37
-			->method('getName')
38
-			->willReturn($propertyName);
39
-
40
-		return $mock;
41
-	}
42
-
43
-	public function testSetAndGetProperties(): void {
44
-		$propsBefore = $this->collection->getProperties();
45
-		$this->assertIsArray($propsBefore);
46
-		$this->assertEmpty($propsBefore);
47
-
48
-		$props = [
49
-			$this->makePropertyMock(self::COLLECTION_NAME),
50
-			$this->makePropertyMock(self::COLLECTION_NAME),
51
-			$this->makePropertyMock(self::COLLECTION_NAME),
52
-		];
53
-
54
-		$this->collection->setProperties($props);
55
-		$propsAfter = $this->collection->getProperties();
56
-		$this->assertIsArray($propsAfter);
57
-		$this->assertCount(count($props), $propsAfter);
58
-	}
59
-
60
-	public function testSetPropertiesMixedInvalid(): void {
61
-		$props = [
62
-			$this->makePropertyMock(self::COLLECTION_NAME),
63
-			$this->makePropertyMock('sneaky_property'),
64
-			$this->makePropertyMock(self::COLLECTION_NAME),
65
-		];
66
-
67
-		$this->expectException(InvalidArgumentException::class);
68
-		$this->collection->setProperties($props);
69
-	}
70
-
71
-	public function testAddProperty(): void {
72
-		$props = [
73
-			$this->makePropertyMock(self::COLLECTION_NAME),
74
-			$this->makePropertyMock(self::COLLECTION_NAME),
75
-			$this->makePropertyMock(self::COLLECTION_NAME),
76
-		];
77
-		$this->collection->setProperties($props);
78
-
79
-		$additionalProperty = $this->makePropertyMock(self::COLLECTION_NAME);
80
-		$this->collection->addProperty($additionalProperty);
81
-
82
-		$propsAfter = $this->collection->getProperties();
83
-		$this->assertCount(count($props) + 1, $propsAfter);
84
-		$this->assertNotFalse(array_search($additionalProperty, $propsAfter, true));
85
-	}
86
-
87
-	public function testAddPropertyInvalid(): void {
88
-		$props = [
89
-			$this->makePropertyMock(self::COLLECTION_NAME),
90
-			$this->makePropertyMock(self::COLLECTION_NAME),
91
-			$this->makePropertyMock(self::COLLECTION_NAME),
92
-		];
93
-		$this->collection->setProperties($props);
94
-
95
-		$additionalProperty = $this->makePropertyMock('sneaky_property');
96
-		$exceptionThrown = false;
97
-		try {
98
-			$this->collection->addProperty($additionalProperty);
99
-		} catch (\InvalidArgumentException $e) {
100
-			$exceptionThrown = true;
101
-		} finally {
102
-			$propsAfter = $this->collection->getProperties();
103
-			$this->assertCount(count($props), $propsAfter);
104
-			$this->assertFalse(array_search($additionalProperty, $propsAfter, true));
105
-			$this->assertTrue($exceptionThrown);
106
-		}
107
-	}
108
-
109
-	public function testRemoveProperty(): void {
110
-		$additionalProperty = $this->makePropertyMock(self::COLLECTION_NAME);
111
-		$props = [
112
-			$this->makePropertyMock(self::COLLECTION_NAME),
113
-			$this->makePropertyMock(self::COLLECTION_NAME),
114
-			$additionalProperty,
115
-			$this->makePropertyMock(self::COLLECTION_NAME),
116
-		];
117
-		$this->collection->setProperties($props);
118
-
119
-		$propsBefore = $this->collection->getProperties();
120
-		$this->collection->removeProperty($additionalProperty);
121
-		$propsAfter = $this->collection->getProperties();
122
-
123
-		$this->assertTrue(count($propsBefore) > count($propsAfter));
124
-		$this->assertCount(count($propsBefore) - 1, $propsAfter);
125
-		$this->assertFalse(array_search($additionalProperty, $propsAfter, true));
126
-	}
127
-
128
-	public function testRemovePropertyNotFound(): void {
129
-		$additionalProperty = $this->makePropertyMock(self::COLLECTION_NAME);
130
-		$props = [
131
-			$this->makePropertyMock(self::COLLECTION_NAME),
132
-			$this->makePropertyMock(self::COLLECTION_NAME),
133
-			$this->makePropertyMock(self::COLLECTION_NAME),
134
-		];
135
-		$this->collection->setProperties($props);
136
-
137
-		$propsBefore = $this->collection->getProperties();
138
-		$this->collection->removeProperty($additionalProperty);
139
-		$propsAfter = $this->collection->getProperties();
140
-
141
-		// no errors, gently
142
-		$this->assertCount(count($propsBefore), $propsAfter);
143
-	}
144
-
145
-	public function testRemovePropertyByValue(): void {
146
-		$additionalProperty = $this->makePropertyMock(self::COLLECTION_NAME);
147
-		$additionalProperty->expects($this->any())
148
-			->method('getValue')
149
-			->willReturn('Lorem ipsum');
150
-
151
-		$additionalPropertyTwo = clone $additionalProperty;
152
-
153
-		$props = [
154
-			$this->makePropertyMock(self::COLLECTION_NAME),
155
-			$this->makePropertyMock(self::COLLECTION_NAME),
156
-			$additionalProperty,
157
-			$this->makePropertyMock(self::COLLECTION_NAME),
158
-			$additionalPropertyTwo
159
-		];
160
-		$this->collection->setProperties($props);
161
-
162
-		$propsBefore = $this->collection->getProperties();
163
-		$this->collection->removePropertyByValue('Lorem ipsum');
164
-		$propsAfter = $this->collection->getProperties();
165
-
166
-		$this->assertTrue(count($propsBefore) > count($propsAfter));
167
-		$this->assertCount(count($propsBefore) - 2, $propsAfter);
168
-		$this->assertFalse(array_search($additionalProperty, $propsAfter, true));
169
-		$this->assertFalse(array_search($additionalPropertyTwo, $propsAfter, true));
170
-	}
171
-
172
-	public function testRemovePropertyByValueNotFound(): void {
173
-		$additionalProperty = $this->makePropertyMock(self::COLLECTION_NAME);
174
-		$additionalProperty->expects($this->any())
175
-			->method('getValue')
176
-			->willReturn('Lorem ipsum');
177
-
178
-		$props = [
179
-			$this->makePropertyMock(self::COLLECTION_NAME),
180
-			$this->makePropertyMock(self::COLLECTION_NAME),
181
-			$this->makePropertyMock(self::COLLECTION_NAME),
182
-		];
183
-		$this->collection->setProperties($props);
184
-
185
-		$propsBefore = $this->collection->getProperties();
186
-		$this->collection->removePropertyByValue('Lorem ipsum');
187
-		$propsAfter = $this->collection->getProperties();
188
-
189
-		// no errors, gently
190
-		$this->assertCount(count($propsBefore), $propsAfter);
191
-	}
20
+    /** @var IAccountPropertyCollection */
21
+    protected $collection;
22
+
23
+    protected const COLLECTION_NAME = 'my_multivalue_property';
24
+
25
+    public function setUp(): void {
26
+        parent::setUp();
27
+
28
+        $this->collection = new AccountPropertyCollection(self::COLLECTION_NAME);
29
+    }
30
+
31
+    /**
32
+     * @return IAccountProperty|MockObject
33
+     */
34
+    protected function makePropertyMock(string $propertyName): MockObject {
35
+        $mock = $this->createMock(IAccountProperty::class);
36
+        $mock->expects($this->any())
37
+            ->method('getName')
38
+            ->willReturn($propertyName);
39
+
40
+        return $mock;
41
+    }
42
+
43
+    public function testSetAndGetProperties(): void {
44
+        $propsBefore = $this->collection->getProperties();
45
+        $this->assertIsArray($propsBefore);
46
+        $this->assertEmpty($propsBefore);
47
+
48
+        $props = [
49
+            $this->makePropertyMock(self::COLLECTION_NAME),
50
+            $this->makePropertyMock(self::COLLECTION_NAME),
51
+            $this->makePropertyMock(self::COLLECTION_NAME),
52
+        ];
53
+
54
+        $this->collection->setProperties($props);
55
+        $propsAfter = $this->collection->getProperties();
56
+        $this->assertIsArray($propsAfter);
57
+        $this->assertCount(count($props), $propsAfter);
58
+    }
59
+
60
+    public function testSetPropertiesMixedInvalid(): void {
61
+        $props = [
62
+            $this->makePropertyMock(self::COLLECTION_NAME),
63
+            $this->makePropertyMock('sneaky_property'),
64
+            $this->makePropertyMock(self::COLLECTION_NAME),
65
+        ];
66
+
67
+        $this->expectException(InvalidArgumentException::class);
68
+        $this->collection->setProperties($props);
69
+    }
70
+
71
+    public function testAddProperty(): void {
72
+        $props = [
73
+            $this->makePropertyMock(self::COLLECTION_NAME),
74
+            $this->makePropertyMock(self::COLLECTION_NAME),
75
+            $this->makePropertyMock(self::COLLECTION_NAME),
76
+        ];
77
+        $this->collection->setProperties($props);
78
+
79
+        $additionalProperty = $this->makePropertyMock(self::COLLECTION_NAME);
80
+        $this->collection->addProperty($additionalProperty);
81
+
82
+        $propsAfter = $this->collection->getProperties();
83
+        $this->assertCount(count($props) + 1, $propsAfter);
84
+        $this->assertNotFalse(array_search($additionalProperty, $propsAfter, true));
85
+    }
86
+
87
+    public function testAddPropertyInvalid(): void {
88
+        $props = [
89
+            $this->makePropertyMock(self::COLLECTION_NAME),
90
+            $this->makePropertyMock(self::COLLECTION_NAME),
91
+            $this->makePropertyMock(self::COLLECTION_NAME),
92
+        ];
93
+        $this->collection->setProperties($props);
94
+
95
+        $additionalProperty = $this->makePropertyMock('sneaky_property');
96
+        $exceptionThrown = false;
97
+        try {
98
+            $this->collection->addProperty($additionalProperty);
99
+        } catch (\InvalidArgumentException $e) {
100
+            $exceptionThrown = true;
101
+        } finally {
102
+            $propsAfter = $this->collection->getProperties();
103
+            $this->assertCount(count($props), $propsAfter);
104
+            $this->assertFalse(array_search($additionalProperty, $propsAfter, true));
105
+            $this->assertTrue($exceptionThrown);
106
+        }
107
+    }
108
+
109
+    public function testRemoveProperty(): void {
110
+        $additionalProperty = $this->makePropertyMock(self::COLLECTION_NAME);
111
+        $props = [
112
+            $this->makePropertyMock(self::COLLECTION_NAME),
113
+            $this->makePropertyMock(self::COLLECTION_NAME),
114
+            $additionalProperty,
115
+            $this->makePropertyMock(self::COLLECTION_NAME),
116
+        ];
117
+        $this->collection->setProperties($props);
118
+
119
+        $propsBefore = $this->collection->getProperties();
120
+        $this->collection->removeProperty($additionalProperty);
121
+        $propsAfter = $this->collection->getProperties();
122
+
123
+        $this->assertTrue(count($propsBefore) > count($propsAfter));
124
+        $this->assertCount(count($propsBefore) - 1, $propsAfter);
125
+        $this->assertFalse(array_search($additionalProperty, $propsAfter, true));
126
+    }
127
+
128
+    public function testRemovePropertyNotFound(): void {
129
+        $additionalProperty = $this->makePropertyMock(self::COLLECTION_NAME);
130
+        $props = [
131
+            $this->makePropertyMock(self::COLLECTION_NAME),
132
+            $this->makePropertyMock(self::COLLECTION_NAME),
133
+            $this->makePropertyMock(self::COLLECTION_NAME),
134
+        ];
135
+        $this->collection->setProperties($props);
136
+
137
+        $propsBefore = $this->collection->getProperties();
138
+        $this->collection->removeProperty($additionalProperty);
139
+        $propsAfter = $this->collection->getProperties();
140
+
141
+        // no errors, gently
142
+        $this->assertCount(count($propsBefore), $propsAfter);
143
+    }
144
+
145
+    public function testRemovePropertyByValue(): void {
146
+        $additionalProperty = $this->makePropertyMock(self::COLLECTION_NAME);
147
+        $additionalProperty->expects($this->any())
148
+            ->method('getValue')
149
+            ->willReturn('Lorem ipsum');
150
+
151
+        $additionalPropertyTwo = clone $additionalProperty;
152
+
153
+        $props = [
154
+            $this->makePropertyMock(self::COLLECTION_NAME),
155
+            $this->makePropertyMock(self::COLLECTION_NAME),
156
+            $additionalProperty,
157
+            $this->makePropertyMock(self::COLLECTION_NAME),
158
+            $additionalPropertyTwo
159
+        ];
160
+        $this->collection->setProperties($props);
161
+
162
+        $propsBefore = $this->collection->getProperties();
163
+        $this->collection->removePropertyByValue('Lorem ipsum');
164
+        $propsAfter = $this->collection->getProperties();
165
+
166
+        $this->assertTrue(count($propsBefore) > count($propsAfter));
167
+        $this->assertCount(count($propsBefore) - 2, $propsAfter);
168
+        $this->assertFalse(array_search($additionalProperty, $propsAfter, true));
169
+        $this->assertFalse(array_search($additionalPropertyTwo, $propsAfter, true));
170
+    }
171
+
172
+    public function testRemovePropertyByValueNotFound(): void {
173
+        $additionalProperty = $this->makePropertyMock(self::COLLECTION_NAME);
174
+        $additionalProperty->expects($this->any())
175
+            ->method('getValue')
176
+            ->willReturn('Lorem ipsum');
177
+
178
+        $props = [
179
+            $this->makePropertyMock(self::COLLECTION_NAME),
180
+            $this->makePropertyMock(self::COLLECTION_NAME),
181
+            $this->makePropertyMock(self::COLLECTION_NAME),
182
+        ];
183
+        $this->collection->setProperties($props);
184
+
185
+        $propsBefore = $this->collection->getProperties();
186
+        $this->collection->removePropertyByValue('Lorem ipsum');
187
+        $propsAfter = $this->collection->getProperties();
188
+
189
+        // no errors, gently
190
+        $this->assertCount(count($propsBefore), $propsAfter);
191
+    }
192 192
 }
Please login to merge, or discard this patch.
tests/lib/Notification/DummyApp.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -12,29 +12,29 @@
 block discarded – undo
12 12
 use OCP\Notification\INotification;
13 13
 
14 14
 class DummyApp implements IApp {
15
-	/**
16
-	 * @param INotification $notification
17
-	 * @throws \InvalidArgumentException When the notification is not valid
18
-	 * @since 9.0.0
19
-	 */
20
-	public function notify(INotification $notification): void {
21
-		// TODO: Implement notify() method.
22
-	}
15
+    /**
16
+     * @param INotification $notification
17
+     * @throws \InvalidArgumentException When the notification is not valid
18
+     * @since 9.0.0
19
+     */
20
+    public function notify(INotification $notification): void {
21
+        // TODO: Implement notify() method.
22
+    }
23 23
 
24
-	/**
25
-	 * @param INotification $notification
26
-	 * @since 9.0.0
27
-	 */
28
-	public function markProcessed(INotification $notification): void {
29
-		// TODO: Implement markProcessed() method.
30
-	}
24
+    /**
25
+     * @param INotification $notification
26
+     * @since 9.0.0
27
+     */
28
+    public function markProcessed(INotification $notification): void {
29
+        // TODO: Implement markProcessed() method.
30
+    }
31 31
 
32
-	/**
33
-	 * @param INotification $notification
34
-	 * @return int
35
-	 * @since 9.0.0
36
-	 */
37
-	public function getCount(INotification $notification): int {
38
-		// TODO: Implement getCount() method.
39
-	}
32
+    /**
33
+     * @param INotification $notification
34
+     * @return int
35
+     * @since 9.0.0
36
+     */
37
+    public function getCount(INotification $notification): int {
38
+        // TODO: Implement getCount() method.
39
+    }
40 40
 }
Please login to merge, or discard this patch.