Skip to content

Commit 6dd56df

Browse files
committed
test: replace addToAssertionCount checkbox tests with DoesNotPerformAssertions in Hooks and DI tests
Signed-off-by: Anna Larch <anna@nextcloud.com> AI-Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 292730e commit 6dd56df

2 files changed

Lines changed: 7 additions & 27 deletions

File tree

tests/lib/AppFramework/Bootstrap/FunctionInjectorTest.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,10 @@ public function testInjectFnNotRegistered(): void {
3434
});
3535
}
3636

37+
#[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions]
3738
public function testInjectFnNotRegisteredButNullable(): void {
3839
(new FunctionInjector($this->container))->injectFn(static function (?Foo $p1): void {
3940
});
40-
41-
// Nothing to assert. No errors means everything is fine.
42-
$this->addToAssertionCount(1);
4341
}
4442

4543
public function testInjectFnByType(): void {
@@ -51,18 +49,13 @@ public function testInjectFnByType(): void {
5149

5250
(new FunctionInjector($this->container))->injectFn(static function (Foo $p1): void {
5351
});
54-
55-
// Nothing to assert. No errors means everything is fine.
56-
$this->addToAssertionCount(1);
5752
}
5853

54+
#[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions]
5955
public function testInjectFnByName(): void {
6056
$this->container->registerParameter('test', 'abc');
6157

6258
(new FunctionInjector($this->container))->injectFn(static function ($test): void {
6359
});
64-
65-
// Nothing to assert. No errors means everything is fine.
66-
$this->addToAssertionCount(1);
6760
}
6861
}

tests/lib/Hooks/BasicEmitterTest.php

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,17 @@ public function testNamedArguments(): void {
148148
$this->emitter->emitEvent('Test', 'test', ['foo' => 'foo', 'bar' => 'bar']);
149149
}
150150

151+
#[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions]
151152
public function testRemoveAllSpecified(): void {
152153
$listener = function (): void {
153154
throw new EmittedException;
154155
};
155156
$this->emitter->listen('Test', 'test', $listener);
156157
$this->emitter->removeListener('Test', 'test', $listener);
157158
$this->emitter->emitEvent('Test', 'test');
158-
159-
$this->addToAssertionCount(1);
160159
}
161160

161+
#[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions]
162162
public function testRemoveWildcardListener(): void {
163163
$listener1 = function (): void {
164164
throw new EmittedException;
@@ -170,10 +170,9 @@ public function testRemoveWildcardListener(): void {
170170
$this->emitter->listen('Test', 'test', $listener2);
171171
$this->emitter->removeListener('Test', 'test');
172172
$this->emitter->emitEvent('Test', 'test');
173-
174-
$this->addToAssertionCount(1);
175173
}
176174

175+
#[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions]
177176
public function testRemoveWildcardMethod(): void {
178177
$listener = function (): void {
179178
throw new EmittedException;
@@ -183,10 +182,9 @@ public function testRemoveWildcardMethod(): void {
183182
$this->emitter->removeListener('Test', null, $listener);
184183
$this->emitter->emitEvent('Test', 'test');
185184
$this->emitter->emitEvent('Test', 'foo');
186-
187-
$this->addToAssertionCount(1);
188185
}
189186

187+
#[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions]
190188
public function testRemoveWildcardScope(): void {
191189
$listener = function (): void {
192190
throw new EmittedException;
@@ -196,10 +194,9 @@ public function testRemoveWildcardScope(): void {
196194
$this->emitter->removeListener(null, 'test', $listener);
197195
$this->emitter->emitEvent('Test', 'test');
198196
$this->emitter->emitEvent('Bar', 'test');
199-
200-
$this->addToAssertionCount(1);
201197
}
202198

199+
#[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions]
203200
public function testRemoveWildcardScopeAndMethod(): void {
204201
$listener = function (): void {
205202
throw new EmittedException;
@@ -211,8 +208,6 @@ public function testRemoveWildcardScopeAndMethod(): void {
211208
$this->emitter->emitEvent('Test', 'test');
212209
$this->emitter->emitEvent('Test', 'foo');
213210
$this->emitter->emitEvent('Bar', 'foo');
214-
215-
$this->addToAssertionCount(1);
216211
}
217212

218213
public function testRemoveKeepOtherCallback(): void {
@@ -228,8 +223,6 @@ public function testRemoveKeepOtherCallback(): void {
228223
$this->emitter->listen('Test', 'test', $listener2);
229224
$this->emitter->removeListener('Test', 'test', $listener1);
230225
$this->emitter->emitEvent('Test', 'test');
231-
232-
$this->addToAssertionCount(1);
233226
}
234227

235228
public function testRemoveKeepOtherMethod(): void {
@@ -242,8 +235,6 @@ public function testRemoveKeepOtherMethod(): void {
242235
$this->emitter->listen('Test', 'foo', $listener);
243236
$this->emitter->removeListener('Test', 'foo', $listener);
244237
$this->emitter->emitEvent('Test', 'test');
245-
246-
$this->addToAssertionCount(1);
247238
}
248239

249240
public function testRemoveKeepOtherScope(): void {
@@ -256,8 +247,6 @@ public function testRemoveKeepOtherScope(): void {
256247
$this->emitter->listen('Bar', 'test', $listener);
257248
$this->emitter->removeListener('Bar', 'test', $listener);
258249
$this->emitter->emitEvent('Test', 'test');
259-
260-
$this->addToAssertionCount(1);
261250
}
262251

263252
public function testRemoveNonExistingName(): void {
@@ -269,7 +258,5 @@ public function testRemoveNonExistingName(): void {
269258
$this->emitter->listen('Test', 'test', $listener);
270259
$this->emitter->removeListener('Bar', 'test', $listener);
271260
$this->emitter->emitEvent('Test', 'test');
272-
273-
$this->addToAssertionCount(1);
274261
}
275262
}

0 commit comments

Comments
 (0)