|
|
|
|
|
|
|
|
use Doctrine\DBAL\Schema\ForeignKeyConstraint; |
|
|
use Doctrine\DBAL\Schema\ForeignKeyConstraint; |
|
|
use Doctrine\DBAL\Schema\Index; |
|
|
use Doctrine\DBAL\Schema\Index; |
|
|
use Doctrine\DBAL\Schema\Schema; |
|
|
use Doctrine\DBAL\Schema\Schema; |
|
|
|
|
|
use Doctrine\DBAL\Schema\SchemaException; |
|
|
use Doctrine\DBAL\Schema\Sequence; |
|
|
use Doctrine\DBAL\Schema\Sequence; |
|
|
use Doctrine\DBAL\Schema\Table; |
|
|
use Doctrine\DBAL\Schema\Table; |
|
|
use OC\DB\Connection; |
|
|
use OC\DB\Connection; |
|
|
|
|
|
|
|
|
->method('migrateToSchema'); |
|
|
->method('migrateToSchema'); |
|
|
|
|
|
|
|
|
$wrappedSchema = $this->createMock(Schema::class); |
|
|
$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') |
|
|
->method('getTables') |
|
|
->willReturn([]); |
|
|
->willReturn([]); |
|
|
$wrappedSchema->expects($this->once()) |
|
|
$wrappedSchema->expects($this->once()) |
|
|
->method('getSequences') |
|
|
->method('getSequences') |
|
|
->willReturn([]);*/ |
|
|
|
|
|
|
|
|
->willReturn([]); |
|
|
|
|
|
|
|
|
$schemaResult = $this->createMock(SchemaWrapper::class); |
|
|
$schemaResult = $this->createMock(SchemaWrapper::class); |
|
|
$schemaResult->expects($this->once()) |
|
|
$schemaResult->expects($this->once()) |
|
|
|
|
|
|
|
|
->willReturn(\str_repeat('a', 30)); |
|
|
->willReturn(\str_repeat('a', 30)); |
|
|
|
|
|
|
|
|
$table = $this->createMock(Table::class); |
|
|
$table = $this->createMock(Table::class); |
|
|
$table->expects($this->once()) |
|
|
|
|
|
|
|
|
$table->expects($this->atLeastOnce()) |
|
|
->method('getName') |
|
|
->method('getName') |
|
|
->willReturn(\str_repeat('a', 30)); |
|
|
->willReturn(\str_repeat('a', 30)); |
|
|
|
|
|
|
|
|
$sequence = $this->createMock(Sequence::class); |
|
|
$sequence = $this->createMock(Sequence::class); |
|
|
$sequence->expects($this->once()) |
|
|
|
|
|
|
|
|
$sequence->expects($this->atLeastOnce()) |
|
|
->method('getName') |
|
|
->method('getName') |
|
|
->willReturn(\str_repeat('a', 30)); |
|
|
->willReturn(\str_repeat('a', 30)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
->method('getSequences') |
|
|
->method('getSequences') |
|
|
->willReturn([$sequence]); |
|
|
->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() { |
|
|
public function testEnsureOracleIdentifierLengthLimitValidWithPrimaryKey() { |
|
|
|
|
|
|
|
|
->method('getSequences') |
|
|
->method('getSequences') |
|
|
->willReturn([]); |
|
|
->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() { |
|
|
public function testEnsureOracleIdentifierLengthLimitValidWithPrimaryKeyDefault() { |
|
|
|
|
|
|
|
|
->method('getSequences') |
|
|
->method('getSequences') |
|
|
->willReturn([]); |
|
|
->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]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
|
|
|
|
|
|
->method('getTables') |
|
|
->method('getTables') |
|
|
->willReturn([$table]); |
|
|
->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]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
|
|
|
|
|
|
->method('getTables') |
|
|
->method('getTables') |
|
|
->willReturn([$table]); |
|
|
->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]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
|
|
|
|
|
|
->method('getTables') |
|
|
->method('getTables') |
|
|
->willReturn([$table]); |
|
|
->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]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
|
|
|
|
|
|
->method('getTables') |
|
|
->method('getTables') |
|
|
->willReturn([$table]); |
|
|
->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]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
|
|
|
|
|
|
->method('getTables') |
|
|
->method('getTables') |
|
|
->willReturn([$table]); |
|
|
->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]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
|
|
|
|
|
|
->method('getTables') |
|
|
->method('getTables') |
|
|
->willReturn([$table]); |
|
|
->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]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
|
|
|
|
|
|
->method('getSequences') |
|
|
->method('getSequences') |
|
|
->willReturn([$sequence]); |
|
|
->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]); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |