Skip to content

Commit d6526ff

Browse files
committed
fix(tests): replace checkbox assertions with DoesNotPerformAssertions (middleware)
Replace `addToAssertionCount(1)` placeholders in AppFramework middleware tests that only verify no exception is thrown. For `SameSiteCookieMiddlewareTest`, two tests already have `expects(self::once())` mock expectations as their real assertion — those just have the redundant placeholder removed. The third test has no expectations and gets `#[DoesNotPerformAssertions]`. For `SecurityMiddlewareTest`, `testIsSubAdminCheck` and `testIsSubAdminAndAdminCheck` get `#[DoesNotPerformAssertions]`. `testRestrictedAppLoggedInPublicPage` and `testRestrictedAppNotLoggedInPublicPage` have `->with()` argument constraints that count as assertions in PHPUnit 11, so the redundant placeholder is simply removed. Part of a broader effort to eliminate checkbox tests (see also #60742, #60747). Signed-off-by: Anna Larch <anna@nextcloud.com> AI-Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 492a42b commit d6526ff

2 files changed

Lines changed: 3 additions & 7 deletions

File tree

tests/lib/AppFramework/Middleware/Security/SameSiteCookieMiddlewareTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ protected function setUp(): void {
5050
$this->middleware = new SameSiteCookieMiddleware($this->request, new MiddlewareUtils($this->reflector, $this->logger));
5151
}
5252

53+
#[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions]
5354
public function testBeforeControllerNoIndex(): void {
5455
$this->request->method('getScriptName')
5556
->willReturn('/ocs/v2.php');
5657

5758
$this->middleware->beforeController(new NoAnnotationController('foo', $this->request), 'foo');
58-
$this->addToAssertionCount(1);
5959
}
6060

6161
public function testBeforeControllerIndexHasAnnotation(): void {
@@ -68,7 +68,6 @@ public function testBeforeControllerIndexHasAnnotation(): void {
6868
->willReturn(true);
6969

7070
$this->middleware->beforeController(new HasAnnotationController('foo', $this->request), 'foo');
71-
$this->addToAssertionCount(1);
7271
}
7372

7473
public function testBeforeControllerIndexNoAnnotationPassingCheck(): void {
@@ -84,7 +83,6 @@ public function testBeforeControllerIndexNoAnnotationPassingCheck(): void {
8483
->willReturn(true);
8584

8685
$this->middleware->beforeController(new NoAnnotationController('foo', $this->request), 'foo');
87-
$this->addToAssertionCount(1);
8886
}
8987

9088
public function testBeforeControllerIndexNoAnnotationFailingCheck(): void {

tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -470,21 +470,21 @@ public function testIsNotSubAdminCheck(string $method): void {
470470
}
471471

472472
#[\PHPUnit\Framework\Attributes\DataProvider('dataNoCSRFRequiredSubAdminRequired')]
473+
#[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions]
473474
public function testIsSubAdminCheck(string $method): void {
474475
$this->reader->reflect($this->controller, $method);
475476
$sec = $this->getMiddleware(true, false, true);
476477

477478
$sec->beforeController($this->controller, $method);
478-
$this->addToAssertionCount(1);
479479
}
480480

481481
#[\PHPUnit\Framework\Attributes\DataProvider('dataNoCSRFRequiredSubAdminRequired')]
482+
#[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions]
482483
public function testIsSubAdminAndAdminCheck(string $method): void {
483484
$this->reader->reflect($this->controller, $method);
484485
$sec = $this->getMiddleware(true, true, true);
485486

486487
$sec->beforeController($this->controller, $method);
487-
$this->addToAssertionCount(1);
488488
}
489489

490490
#[\PHPUnit\Framework\Attributes\DataProvider('dataNoCSRFRequired')]
@@ -506,7 +506,6 @@ public function testRestrictedAppLoggedInPublicPage(string $method): void {
506506
->willReturn(false);
507507

508508
$middleware->beforeController($this->controller, $method);
509-
$this->addToAssertionCount(1);
510509
}
511510

512511
#[\PHPUnit\Framework\Attributes\DataProvider('dataNoAdminRequiredNoCSRFRequiredPublicPage')]
@@ -523,7 +522,6 @@ public function testRestrictedAppNotLoggedInPublicPage(string $method): void {
523522
->willReturn(false);
524523

525524
$middleware->beforeController($this->controller, $method);
526-
$this->addToAssertionCount(1);
527525
}
528526

529527
#[\PHPUnit\Framework\Attributes\DataProvider('dataNoAdminRequiredNoCSRFRequired')]

0 commit comments

Comments
 (0)