Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2019-11-27 17:27:18 +0300
committerRoeland Jago Douma <roeland@famdouma.nl>2019-11-27 17:27:18 +0300
commit3a7cf40aaa678bea1df143d2982d603b7a334eec (patch)
tree63c1e3ad7f7f401d14411a4d44c523632906afc9 /tests/lib/DB
parent0568b012672d650c6b5a49e72c4028dde5463c60 (diff)
Mode to modern phpunit
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'tests/lib/DB')
-rw-r--r--tests/lib/DB/ConnectionTest.php16
-rw-r--r--tests/lib/DB/MigrationsTest.php68
-rw-r--r--tests/lib/DB/MigratorTest.php6
-rw-r--r--tests/lib/DB/QueryBuilder/QueryBuilderTest.php2
4 files changed, 46 insertions, 46 deletions
diff --git a/tests/lib/DB/ConnectionTest.php b/tests/lib/DB/ConnectionTest.php
index 4683c53d339..607674d7a38 100644
--- a/tests/lib/DB/ConnectionTest.php
+++ b/tests/lib/DB/ConnectionTest.php
@@ -42,12 +42,12 @@ class ConnectionTest extends \Test\TestCase {
}
}
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection();
}
- public function tearDown(): void {
+ protected function tearDown(): void {
parent::tearDown();
$this->connection->dropTable('table');
}
@@ -157,10 +157,10 @@ class ConnectionTest extends \Test\TestCase {
$this->assertEquals('bar', $this->getTextValueByIntergerField(1));
}
- /**
- * @expectedException \OCP\PreConditionNotMetException
- */
+
public function testSetValuesOverWritePreconditionFailed() {
+ $this->expectException(\OCP\PreConditionNotMetException::class);
+
$this->makeTestTable();
$this->connection->setValues('table', [
'integerfield' => 1
@@ -335,10 +335,10 @@ class ConnectionTest extends \Test\TestCase {
$this->assertEquals(0, $result);
}
- /**
- * @expectedException \Doctrine\DBAL\Exception\UniqueConstraintViolationException
- */
+
public function testUniqueConstraintViolating() {
+ $this->expectException(\Doctrine\DBAL\Exception\UniqueConstraintViolationException::class);
+
$this->makeTestTable();
$testQuery = 'INSERT INTO `*PREFIX*table` (`integerfield`, `textfield`) VALUES(?, ?)';
diff --git a/tests/lib/DB/MigrationsTest.php b/tests/lib/DB/MigrationsTest.php
index 8f38b3addd0..58f775febb0 100644
--- a/tests/lib/DB/MigrationsTest.php
+++ b/tests/lib/DB/MigrationsTest.php
@@ -36,7 +36,7 @@ class MigrationsTest extends \Test\TestCase {
/** @var \PHPUnit_Framework_MockObject_MockObject | IDBConnection $db */
private $db;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->db = $this->createMock(Connection::class);
@@ -60,27 +60,27 @@ class MigrationsTest extends \Test\TestCase {
$this->assertEquals('test_oc_migrations', $this->migrationService->getMigrationsTableName());
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage Version 20170130180000 is unknown.
- */
+
public function testExecuteUnknownStep() {
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('Version 20170130180000 is unknown.');
+
$this->migrationService->executeStep('20170130180000');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage App not found
- */
+
public function testUnknownApp() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('App not found');
+
$migrationService = new MigrationService('unknown-bloody-app', $this->db);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Migration step 'X' is unknown
- */
+
public function testExecuteStepWithUnknownClass() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Migration step \'X\' is unknown');
+
$this->migrationService = $this->getMockBuilder(MigrationService::class)
->setMethods(['findMigrations'])
->setConstructorArgs(['testing', $this->db])
@@ -375,10 +375,10 @@ class MigrationsTest extends \Test\TestCase {
self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testEnsureOracleIdentifierLengthLimitTooLongTableName() {
+ $this->expectException(\InvalidArgumentException::class);
+
$table = $this->createMock(Table::class);
$table->expects($this->any())
->method('getName')
@@ -400,10 +400,10 @@ class MigrationsTest extends \Test\TestCase {
self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testEnsureOracleIdentifierLengthLimitTooLongPrimaryWithDefault() {
+ $this->expectException(\InvalidArgumentException::class);
+
$defaultName = 'PRIMARY';
if ($this->db->getDatabasePlatform() instanceof PostgreSqlPlatform) {
$defaultName = \str_repeat('a', 27) . '_' . \str_repeat('b', 30) . '_seq';
@@ -453,10 +453,10 @@ class MigrationsTest extends \Test\TestCase {
self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testEnsureOracleIdentifierLengthLimitTooLongPrimaryWithName() {
+ $this->expectException(\InvalidArgumentException::class);
+
$index = $this->createMock(Index::class);
$index->expects($this->any())
->method('getName')
@@ -496,10 +496,10 @@ class MigrationsTest extends \Test\TestCase {
self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testEnsureOracleIdentifierLengthLimitTooLongColumnName() {
+ $this->expectException(\InvalidArgumentException::class);
+
$column = $this->createMock(Column::class);
$column->expects($this->any())
->method('getName')
@@ -530,10 +530,10 @@ class MigrationsTest extends \Test\TestCase {
self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testEnsureOracleIdentifierLengthLimitTooLongIndexName() {
+ $this->expectException(\InvalidArgumentException::class);
+
$index = $this->createMock(Index::class);
$index->expects($this->any())
->method('getName')
@@ -567,10 +567,10 @@ class MigrationsTest extends \Test\TestCase {
self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testEnsureOracleIdentifierLengthLimitTooLongForeignKeyName() {
+ $this->expectException(\InvalidArgumentException::class);
+
$foreignKey = $this->createMock(ForeignKeyConstraint::class);
$foreignKey->expects($this->any())
->method('getName')
@@ -607,10 +607,10 @@ class MigrationsTest extends \Test\TestCase {
self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testEnsureOracleIdentifierLengthLimitTooLongSequenceName() {
+ $this->expectException(\InvalidArgumentException::class);
+
$sequence = $this->createMock(Sequence::class);
$sequence->expects($this->any())
->method('getName')
diff --git a/tests/lib/DB/MigratorTest.php b/tests/lib/DB/MigratorTest.php
index ca778fd4e2f..e5cc28654e4 100644
--- a/tests/lib/DB/MigratorTest.php
+++ b/tests/lib/DB/MigratorTest.php
@@ -102,10 +102,10 @@ class MigratorTest extends \Test\TestCase {
return $this->connection->getDriver() instanceof \Doctrine\DBAL\Driver\PDOSqlite\Driver;
}
- /**
- * @expectedException \OC\DB\MigrationException
- */
+
public function testDuplicateKeyUpgrade() {
+ $this->expectException(\OC\DB\MigrationException::class);
+
if ($this->isSQLite()) {
$this->markTestSkipped('sqlite does not throw errors when creating a new key on existing data');
}
diff --git a/tests/lib/DB/QueryBuilder/QueryBuilderTest.php b/tests/lib/DB/QueryBuilder/QueryBuilderTest.php
index e9878d33d85..a9542e2d616 100644
--- a/tests/lib/DB/QueryBuilder/QueryBuilderTest.php
+++ b/tests/lib/DB/QueryBuilder/QueryBuilderTest.php
@@ -1152,7 +1152,7 @@ class QueryBuilderTest extends \Test\TestCase {
$actual = $qB->getLastInsertId();
$this->assertNotNull($actual);
- $this->assertInternalType('int', $actual);
+ $this->assertIsInt($actual);
$this->assertEquals($this->connection->lastInsertId('*PREFIX*properties'), $actual);
$qB->delete('properties')