Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update the tests to the comparison logic
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Dec 17, 2018
commit 85a0e10b4f3caec73de26e26e71bd6895358c916
110 changes: 95 additions & 15 deletions tests/lib/DB/MigrationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
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;
Expand Down Expand Up @@ -102,13 +103,12 @@ public function testExecuteStepWithSchemaChange() {
->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())
Expand Down Expand Up @@ -239,12 +239,12 @@ public function testEnsureOracleIdentifierLengthLimitValid() {
->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));

Expand All @@ -269,7 +269,15 @@ public function testEnsureOracleIdentifierLengthLimitValid() {
->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() {
Expand Down Expand Up @@ -304,7 +312,15 @@ public function testEnsureOracleIdentifierLengthLimitValidWithPrimaryKey() {
->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() {
Expand Down Expand Up @@ -349,7 +365,15 @@ public function testEnsureOracleIdentifierLengthLimitValidWithPrimaryKeyDefault(
->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]);
}

/**
Expand All @@ -366,7 +390,15 @@ public function testEnsureOracleIdentifierLengthLimitTooLongTableName() {
->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]);
}

/**
Expand Down Expand Up @@ -411,7 +443,15 @@ public function testEnsureOracleIdentifierLengthLimitTooLongPrimaryWithDefault()
->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]);
}

/**
Expand Down Expand Up @@ -446,7 +486,15 @@ public function testEnsureOracleIdentifierLengthLimitTooLongPrimaryWithName() {
->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]);
}

/**
Expand All @@ -472,7 +520,15 @@ public function testEnsureOracleIdentifierLengthLimitTooLongColumnName() {
->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]);
}

/**
Expand Down Expand Up @@ -501,7 +557,15 @@ public function testEnsureOracleIdentifierLengthLimitTooLongIndexName() {
->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]);
}

/**
Expand Down Expand Up @@ -533,7 +597,15 @@ public function testEnsureOracleIdentifierLengthLimitTooLongForeignKeyName() {
->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]);
}

/**
Expand All @@ -553,6 +625,14 @@ public function testEnsureOracleIdentifierLengthLimitTooLongSequenceName() {
->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]);
}
}