diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2019-11-27 15:27:18 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2019-11-27 15:27:18 +0100 |
commit | 3a7cf40aaa678bea1df143d2982d603b7a334eec (patch) | |
tree | 63c1e3ad7f7f401d14411a4d44c523632906afc9 /tests/lib/DB/MigrationsTest.php | |
parent | 0568b012672d650c6b5a49e72c4028dde5463c60 (diff) | |
download | nextcloud-server-3a7cf40aaa678bea1df143d2982d603b7a334eec.tar.gz nextcloud-server-3a7cf40aaa678bea1df143d2982d603b7a334eec.zip |
Mode to modern phpunit
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'tests/lib/DB/MigrationsTest.php')
-rw-r--r-- | tests/lib/DB/MigrationsTest.php | 68 |
1 files changed, 34 insertions, 34 deletions
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') |