mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-05 11:27:07 +00:00
BlockStateUpgraderTest: fixed tests for 7ff0ae19d65e3b3029246b51de0e361cee6a1a01
This commit is contained in:
parent
7ff0ae19d6
commit
8d7f1a8557
@ -47,11 +47,11 @@ class BlockStateUpgraderTest extends TestCase{
|
||||
}
|
||||
|
||||
private function getNewSchema() : BlockStateUpgradeSchema{
|
||||
return $this->getNewSchemaVersion(PHP_INT_MAX);
|
||||
return $this->getNewSchemaVersion(PHP_INT_MAX, 0);
|
||||
}
|
||||
|
||||
private function getNewSchemaVersion(int $versionId) : BlockStateUpgradeSchema{
|
||||
$schema = new BlockStateUpgradeSchema(($versionId >> 24) & 0xff, ($versionId >> 16) & 0xff, ($versionId >> 8) & 0xff, $versionId & 0xff, 0);
|
||||
private function getNewSchemaVersion(int $versionId, int $schemaId) : BlockStateUpgradeSchema{
|
||||
$schema = new BlockStateUpgradeSchema(($versionId >> 24) & 0xff, ($versionId >> 16) & 0xff, ($versionId >> 8) & 0xff, $versionId & 0xff, $schemaId);
|
||||
$this->upgrader->addSchema($schema);
|
||||
return $schema;
|
||||
}
|
||||
@ -211,20 +211,23 @@ class BlockStateUpgraderTest extends TestCase{
|
||||
}
|
||||
|
||||
/**
|
||||
* @phpstan-return \Generator<int, array{int, int, bool}, void, void>
|
||||
* @phpstan-return \Generator<int, array{int, int, bool, int}, void, void>
|
||||
*/
|
||||
public static function upgraderVersionCompatibilityProvider() : \Generator{
|
||||
yield [0x1_00_00_00, 0x1_00_00_00, true]; //Same version: must be altered - this may be a backwards-compatible change that Mojang didn't bother to bump for
|
||||
yield [0x1_00_01_00, 0x1_00_00_00, true]; //Schema newer than block: must be altered
|
||||
yield [0x1_00_00_00, 0x1_00_01_00, false]; //Block newer than schema: block must NOT be altered
|
||||
yield [0x1_00_00_00, 0x1_00_00_00, true, 2]; //Same version, multiple schemas targeting version - must be altered, we don't know which schemas are applicable
|
||||
yield [0x1_00_00_00, 0x1_00_00_00, false, 1]; //Same version, one schema targeting version - do not change
|
||||
yield [0x1_00_01_00, 0x1_00_00_00, true, 1]; //Schema newer than block: must be altered
|
||||
yield [0x1_00_00_00, 0x1_00_01_00, false, 1]; //Block newer than schema: block must NOT be altered
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider upgraderVersionCompatibilityProvider
|
||||
*/
|
||||
public function testUpgraderVersionCompatibility(int $schemaVersion, int $stateVersion, bool $shouldChange) : void{
|
||||
$schema = $this->getNewSchemaVersion($schemaVersion);
|
||||
$schema->renamedIds[self::TEST_BLOCK] = self::TEST_BLOCK_2;
|
||||
public function testUpgraderVersionCompatibility(int $schemaVersion, int $stateVersion, bool $shouldChange, int $schemaCount) : void{
|
||||
for($i = 0; $i < $schemaCount; $i++){
|
||||
$schema = $this->getNewSchemaVersion($schemaVersion, $i);
|
||||
$schema->renamedIds[self::TEST_BLOCK] = self::TEST_BLOCK_2;
|
||||
}
|
||||
|
||||
$getStateData = fn() => new BlockStateData(
|
||||
self::TEST_BLOCK,
|
||||
|
Loading…
x
Reference in New Issue
Block a user