diff --git a/tests/lib/DB/MigratorTest.php b/tests/lib/DB/MigratorTest.php index 099419884e072..da132a9d85d63 100644 --- a/tests/lib/DB/MigratorTest.php +++ b/tests/lib/DB/MigratorTest.php @@ -129,6 +129,7 @@ private function getSchemaConfig() { return $config; } + #[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions] public function testUpgrade(): void { [$startSchema, $endSchema] = $this->getDuplicateKeySchemas(); $migrator = $this->getMigrator(); @@ -139,9 +140,9 @@ public function testUpgrade(): void { $this->connection->insert($this->tableName, ['id' => 3, 'name' => 'qwerty']); $migrator->migrate($endSchema); - $this->addToAssertionCount(1); } + #[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions] public function testUpgradeDifferentPrefix(): void { $oldTablePrefix = $this->config->getSystemValueString('dbtableprefix', 'oc_'); @@ -157,7 +158,6 @@ public function testUpgradeDifferentPrefix(): void { $this->connection->insert($this->tableName, ['id' => 3, 'name' => 'qwerty']); $migrator->migrate($endSchema); - $this->addToAssertionCount(1); $this->config->setSystemValue('dbtableprefix', $oldTablePrefix); } @@ -171,14 +171,12 @@ public function testInsertAfterUpgrade(): void { $this->connection->insert($this->tableName, ['id' => 1, 'name' => 'foo']); $this->connection->insert($this->tableName, ['id' => 2, 'name' => 'bar']); - try { - $this->connection->insert($this->tableName, ['id' => 2, 'name' => 'qwerty']); - $this->fail('Expected duplicate key insert to fail'); - } catch (Exception $e) { - $this->addToAssertionCount(1); - } + + $this->expectException(\Doctrine\DBAL\Exception\UniqueConstraintViolationException::class); + $this->connection->insert($this->tableName, ['id' => 2, 'name' => 'qwerty']); } + #[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions] public function testAddingPrimaryKeyWithAutoIncrement(): void { $startSchema = new Schema([], [], $this->getSchemaConfig()); $table = $startSchema->createTable($this->tableName); @@ -195,10 +193,9 @@ public function testAddingPrimaryKeyWithAutoIncrement(): void { $migrator->migrate($startSchema); $migrator->migrate($endSchema); - - $this->addToAssertionCount(1); } + #[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions] public function testReservedKeywords(): void { $startSchema = new Schema([], [], $this->getSchemaConfig()); $table = $startSchema->createTable($this->tableName); @@ -216,13 +213,12 @@ public function testReservedKeywords(): void { $migrator->migrate($startSchema); $migrator->migrate($endSchema); - - $this->addToAssertionCount(1); } /** * Test for nextcloud/server#36803 */ + #[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions] public function testColumnCommentsInUpdate(): void { $startSchema = new Schema([], [], $this->getSchemaConfig()); $table = $startSchema->createTable($this->tableName); @@ -240,8 +236,6 @@ public function testColumnCommentsInUpdate(): void { $migrator->migrate($startSchema); $migrator->migrate($endSchema); - - $this->addToAssertionCount(1); } public function testAddingForeignKey(): void { @@ -303,12 +297,10 @@ public function testNotNullEmptyValuesFailOracle(int $parameterType, $value, str $this->expectException(\Doctrine\DBAL\Exception\NotNullConstraintViolationException::class); } - $this->connection->insert( + $this->assertSame(1, $this->connection->insert( $this->tableName, ['id' => 1, 'will_it_blend' => $value], ['id' => ParameterType::INTEGER, 'will_it_blend' => $parameterType], - ); - - $this->addToAssertionCount(1); + )); } } diff --git a/tests/lib/DB/QueryBuilder/QueryBuilderTest.php b/tests/lib/DB/QueryBuilder/QueryBuilderTest.php index e39ba0b78c62c..b5071c597bdd8 100644 --- a/tests/lib/DB/QueryBuilder/QueryBuilderTest.php +++ b/tests/lib/DB/QueryBuilder/QueryBuilderTest.php @@ -1151,7 +1151,6 @@ public function testGetLastInsertId(): void { $qB->getLastInsertId(); $this->fail('getLastInsertId() should throw an exception, when being called before insert()'); } catch (\BadMethodCallException $e) { - $this->addToAssertionCount(1); } $qB->insert('properties') @@ -1177,7 +1176,6 @@ public function testGetLastInsertId(): void { $qB->getLastInsertId(); $this->fail('getLastInsertId() should throw an exception, when being called after delete()'); } catch (\BadMethodCallException $e) { - $this->addToAssertionCount(1); } }