diff options
author | blizzz <blizzz@arthur-schiwon.de> | 2019-01-03 14:18:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-03 14:18:13 +0100 |
commit | 68952306aa3309286b6cd685976c2cdee674268a (patch) | |
tree | c37fb65becf5e85ad97a1e657ef67d4d16e14140 /tests | |
parent | c7399379c9f56d95eb62ebcebd4b5f950d412bce (diff) | |
parent | 85a0e10b4f3caec73de26e26e71bd6895358c916 (diff) | |
download | nextcloud-server-68952306aa3309286b6cd685976c2cdee674268a.tar.gz nextcloud-server-68952306aa3309286b6cd685976c2cdee674268a.zip |
Merge pull request #10555 from nextcloud/bugfix/10518/only-check-added-items
Only enforce schema limits for supported apps
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/DB/MigrationsTest.php | 110 |
1 files changed, 95 insertions, 15 deletions
diff --git a/tests/lib/DB/MigrationsTest.php b/tests/lib/DB/MigrationsTest.php index 7e201191087..8654c83a545 100644 --- a/tests/lib/DB/MigrationsTest.php +++ b/tests/lib/DB/MigrationsTest.php @@ -16,6 +16,7 @@ use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\ForeignKeyConstraint; use Doctrine\DBAL\Schema\Index; use Doctrine\DBAL\Schema\Schema; +use Doctrine\DBAL\Schema\SchemaException; use Doctrine\DBAL\Schema\Sequence; use Doctrine\DBAL\Schema\Table; use OC\DB\Connection; @@ -102,13 +103,12 @@ class MigrationsTest extends \Test\TestCase { ->method('migrateToSchema'); $wrappedSchema = $this->createMock(Schema::class); - // TODO re-enable once stable14 is branched of: https://github.com/nextcloud/server/issues/10518 - /*$wrappedSchema->expects($this->once()) + $wrappedSchema->expects($this->once()) ->method('getTables') ->willReturn([]); $wrappedSchema->expects($this->once()) ->method('getSequences') - ->willReturn([]);*/ + ->willReturn([]); $schemaResult = $this->createMock(SchemaWrapper::class); $schemaResult->expects($this->once()) @@ -239,12 +239,12 @@ class MigrationsTest extends \Test\TestCase { ->willReturn(\str_repeat('a', 30)); $table = $this->createMock(Table::class); - $table->expects($this->once()) + $table->expects($this->atLeastOnce()) ->method('getName') ->willReturn(\str_repeat('a', 30)); $sequence = $this->createMock(Sequence::class); - $sequence->expects($this->once()) + $sequence->expects($this->atLeastOnce()) ->method('getName') ->willReturn(\str_repeat('a', 30)); @@ -269,7 +269,15 @@ class MigrationsTest extends \Test\TestCase { ->method('getSequences') ->willReturn([$sequence]); - self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema, 3]); + $sourceSchema = $this->createMock(Schema::class); + $sourceSchema->expects($this->any()) + ->method('getTable') + ->willThrowException(new SchemaException()); + $sourceSchema->expects($this->any()) + ->method('hasSequence') + ->willReturn(false); + + self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]); } public function testEnsureOracleIdentifierLengthLimitValidWithPrimaryKey() { @@ -304,7 +312,15 @@ class MigrationsTest extends \Test\TestCase { ->method('getSequences') ->willReturn([]); - self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema, 3]); + $sourceSchema = $this->createMock(Schema::class); + $sourceSchema->expects($this->any()) + ->method('getTable') + ->willThrowException(new SchemaException()); + $sourceSchema->expects($this->any()) + ->method('hasSequence') + ->willReturn(false); + + self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]); } public function testEnsureOracleIdentifierLengthLimitValidWithPrimaryKeyDefault() { @@ -349,7 +365,15 @@ class MigrationsTest extends \Test\TestCase { ->method('getSequences') ->willReturn([]); - self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema, 3]); + $sourceSchema = $this->createMock(Schema::class); + $sourceSchema->expects($this->any()) + ->method('getTable') + ->willThrowException(new SchemaException()); + $sourceSchema->expects($this->any()) + ->method('hasSequence') + ->willReturn(false); + + self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]); } /** @@ -366,7 +390,15 @@ class MigrationsTest extends \Test\TestCase { ->method('getTables') ->willReturn([$table]); - self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema, 3]); + $sourceSchema = $this->createMock(Schema::class); + $sourceSchema->expects($this->any()) + ->method('getTable') + ->willThrowException(new SchemaException()); + $sourceSchema->expects($this->any()) + ->method('hasSequence') + ->willReturn(false); + + self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]); } /** @@ -411,7 +443,15 @@ class MigrationsTest extends \Test\TestCase { ->method('getTables') ->willReturn([$table]); - self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema, 3]); + $sourceSchema = $this->createMock(Schema::class); + $sourceSchema->expects($this->any()) + ->method('getTable') + ->willThrowException(new SchemaException()); + $sourceSchema->expects($this->any()) + ->method('hasSequence') + ->willReturn(false); + + self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]); } /** @@ -446,7 +486,15 @@ class MigrationsTest extends \Test\TestCase { ->method('getTables') ->willReturn([$table]); - self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema, 3]); + $sourceSchema = $this->createMock(Schema::class); + $sourceSchema->expects($this->any()) + ->method('getTable') + ->willThrowException(new SchemaException()); + $sourceSchema->expects($this->any()) + ->method('hasSequence') + ->willReturn(false); + + self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]); } /** @@ -472,7 +520,15 @@ class MigrationsTest extends \Test\TestCase { ->method('getTables') ->willReturn([$table]); - self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema, 3]); + $sourceSchema = $this->createMock(Schema::class); + $sourceSchema->expects($this->any()) + ->method('getTable') + ->willThrowException(new SchemaException()); + $sourceSchema->expects($this->any()) + ->method('hasSequence') + ->willReturn(false); + + self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]); } /** @@ -501,7 +557,15 @@ class MigrationsTest extends \Test\TestCase { ->method('getTables') ->willReturn([$table]); - self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema, 3]); + $sourceSchema = $this->createMock(Schema::class); + $sourceSchema->expects($this->any()) + ->method('getTable') + ->willThrowException(new SchemaException()); + $sourceSchema->expects($this->any()) + ->method('hasSequence') + ->willReturn(false); + + self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]); } /** @@ -533,7 +597,15 @@ class MigrationsTest extends \Test\TestCase { ->method('getTables') ->willReturn([$table]); - self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema, 3]); + $sourceSchema = $this->createMock(Schema::class); + $sourceSchema->expects($this->any()) + ->method('getTable') + ->willThrowException(new SchemaException()); + $sourceSchema->expects($this->any()) + ->method('hasSequence') + ->willReturn(false); + + self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]); } /** @@ -553,6 +625,14 @@ class MigrationsTest extends \Test\TestCase { ->method('getSequences') ->willReturn([$sequence]); - self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$schema, 3]); + $sourceSchema = $this->createMock(Schema::class); + $sourceSchema->expects($this->any()) + ->method('getTable') + ->willThrowException(new SchemaException()); + $sourceSchema->expects($this->any()) + ->method('hasSequence') + ->willReturn(false); + + self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]); } } |