Skip to content

Commit 7ee254c

Browse files
Merge pull request #60785 from nextcloud/backport/60742/stable34
[stable34] test: replace checkbox assertions with real assertions or DoesNotPerformAssertions
2 parents 74b1d75 + edc91a6 commit 7ee254c

5 files changed

Lines changed: 11 additions & 25 deletions

File tree

tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ protected function setUp(): void {
5353
);
5454
}
5555

56+
#[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions]
5657
public function testBeforeControllerNoPublicShareController(): void {
5758
$controller = $this->createMock(Controller::class);
5859

5960
$this->middleware->beforeController($controller, 'method');
60-
$this->assertTrue(true);
6161
}
6262

6363
public static function dataShareApi(): array {
@@ -157,14 +157,11 @@ public function testBeforeControllerValidTokenAuthenticateMethod(): void {
157157
->with('token', null)
158158
->willReturn('myToken');
159159

160-
$controller->method('isValidToken')
161-
->willReturn(true);
162-
163-
$controller->method('isPasswordProtected')
160+
$controller->expects($this->once())
161+
->method('isValidToken')
164162
->willReturn(true);
165163

166164
$this->middleware->beforeController($controller, 'authenticate');
167-
$this->assertTrue(true);
168165
}
169166

170167
public function testBeforeControllerValidTokenShowAuthenticateMethod(): void {
@@ -182,14 +179,11 @@ public function testBeforeControllerValidTokenShowAuthenticateMethod(): void {
182179
->with('token', null)
183180
->willReturn('myToken');
184181

185-
$controller->method('isValidToken')
186-
->willReturn(true);
187-
188-
$controller->method('isPasswordProtected')
182+
$controller->expects($this->once())
183+
->method('isValidToken')
189184
->willReturn(true);
190185

191186
$this->middleware->beforeController($controller, 'showAuthenticate');
192-
$this->assertTrue(true);
193187
}
194188

195189
public function testBeforeControllerAuthPublicShareController(): void {

tests/lib/DB/QueryBuilder/Sharded/SharedQueryBuilderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,24 @@ public function testGetPrimaryKeyParam(): void {
6565
$this->assertEquals([], $query->getShardKeys());
6666
}
6767

68+
#[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions]
6869
public function testValidateWithShardKey(): void {
6970
$query = $this->getQueryBuilder('filecache', 'storage', 'fileid');
7071
$query->select('fileid', 'path')
7172
->from('filecache')
7273
->where($query->expr()->eq('storage', $query->createNamedParameter(10)));
7374

7475
$query->validate();
75-
$this->assertTrue(true);
7676
}
7777

78+
#[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions]
7879
public function testValidateWithPrimaryKey(): void {
7980
$query = $this->getQueryBuilder('filecache', 'storage', 'fileid');
8081
$query->select('fileid', 'path')
8182
->from('filecache')
8283
->where($query->expr()->in('fileid', $query->createNamedParameter([10, 11], IQueryBuilder::PARAM_INT)));
8384

8485
$query->validate();
85-
$this->assertTrue(true);
8686
}
8787

8888
public function testValidateWithNoKey(): void {
@@ -96,14 +96,14 @@ public function testValidateWithNoKey(): void {
9696
$this->fail('exception expected');
9797
}
9898

99+
#[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions]
99100
public function testValidateNonSharedTable(): void {
100101
$query = $this->getQueryBuilder('filecache', 'storage', 'fileid');
101102
$query->select('configvalue')
102103
->from('appconfig')
103104
->where($query->expr()->eq('configkey', $query->createNamedParameter('test')));
104105

105106
$query->validate();
106-
$this->assertTrue(true);
107107
}
108108

109109
public function testGetShardKeyMultipleSingleParam(): void {

tests/lib/Files/SimpleFS/InMemoryFileTest.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,9 @@ public function testPutContent(): void {
4545
self::assertEquals('test', $this->testPdf->getContent());
4646
}
4747

48-
/**
49-
* Asserts that delete() doesn't rise an exception.
50-
*
51-
* @return void
52-
*/
48+
#[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions]
5349
public function testDelete(): void {
5450
$this->testPdf->delete();
55-
// assert true, otherwise phpunit complains about not doing any assert
56-
self::assertTrue(true);
5751
}
5852

5953
/**

tests/lib/Repair/ClearFrontendCachesTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,5 @@ public function testRun(): void {
4848
->willReturn($imagePathCache);
4949

5050
$this->repair->run($this->outputMock);
51-
$this->assertTrue(true);
5251
}
5352
}

tests/lib/Talk/BrokerTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,9 @@ public function testHasBackend(): void {
103103
}
104104

105105
public function testNewConversationOptions(): void {
106-
$this->broker->newConversationOptions();
106+
$options = $this->broker->newConversationOptions();
107107

108-
// Nothing to assert
109-
$this->addToAssertionCount(1);
108+
$this->assertInstanceOf(IConversationOptions::class, $options);
110109
}
111110

112111
public function testCreateConversation(): void {

0 commit comments

Comments
 (0)