mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Merge branch 'minor-next' into major-next
This commit is contained in:
@ -35,3 +35,18 @@ parameters:
|
||||
count: 1
|
||||
path: ../../../src/world/generator/normal/Normal.php
|
||||
|
||||
-
|
||||
message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertFalse\\(\\) with false will always evaluate to true\\.$#"
|
||||
count: 1
|
||||
path: ../../phpunit/promise/PromiseTest.php
|
||||
|
||||
-
|
||||
message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertTrue\\(\\) with false and 'All promise should…' will always evaluate to false\\.$#"
|
||||
count: 1
|
||||
path: ../../phpunit/promise/PromiseTest.php
|
||||
|
||||
-
|
||||
message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertTrue\\(\\) with false will always evaluate to false\\.$#"
|
||||
count: 2
|
||||
path: ../../phpunit/promise/PromiseTest.php
|
||||
|
||||
|
@ -30,7 +30,7 @@ require dirname(__DIR__, 3) . '/vendor/autoload.php';
|
||||
|
||||
/* This script needs to be re-run after any intentional blockfactory change (adding or removing a block state). */
|
||||
|
||||
$factory = new \pocketmine\block\RuntimeBlockStateRegistry();
|
||||
$factory = new RuntimeBlockStateRegistry();
|
||||
$remaps = [];
|
||||
$new = [];
|
||||
foreach(RuntimeBlockStateRegistry::getInstance()->getAllKnownStates() as $index => $block){
|
||||
@ -44,7 +44,7 @@ $oldTablePath = __DIR__ . '/block_factory_consistency_check.json';
|
||||
if(file_exists($oldTablePath)){
|
||||
$oldTable = json_decode(file_get_contents($oldTablePath), true);
|
||||
if(!is_array($oldTable)){
|
||||
throw new \pocketmine\utils\AssumptionFailedError("Old table should be array{knownStates: array<string, string>, stateDataBits: int}");
|
||||
throw new AssumptionFailedError("Old table should be array{knownStates: array<string, string>, stateDataBits: int}");
|
||||
}
|
||||
$old = [];
|
||||
/**
|
||||
|
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\data\bedrock;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
|
||||
class DyeColorIdMapTest extends TestCase{
|
||||
|
||||
public function testAllColorsMapped() : void{
|
||||
foreach(DyeColor::cases() as $color){
|
||||
$id = DyeColorIdMap::getInstance()->toId($color);
|
||||
$color2 = DyeColorIdMap::getInstance()->fromId($id);
|
||||
self::assertTrue($color === $color2);
|
||||
}
|
||||
}
|
||||
}
|
@ -39,4 +39,110 @@ final class PromiseTest extends TestCase{
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function testAllPreResolved() : void{
|
||||
$resolver = new PromiseResolver();
|
||||
$resolver->resolve(1);
|
||||
|
||||
$allPromise = Promise::all([$resolver->getPromise()]);
|
||||
$done = false;
|
||||
$allPromise->onCompletion(
|
||||
function($value) use (&$done) : void{
|
||||
$done = true;
|
||||
self::assertEquals([1], $value);
|
||||
},
|
||||
function() use (&$done) : void{
|
||||
$done = true;
|
||||
self::fail("Promise was rejected");
|
||||
}
|
||||
);
|
||||
self::assertTrue($done);
|
||||
}
|
||||
|
||||
public function testAllPostResolved() : void{
|
||||
$resolver = new PromiseResolver();
|
||||
|
||||
$allPromise = Promise::all([$resolver->getPromise()]);
|
||||
$done = false;
|
||||
$allPromise->onCompletion(
|
||||
function($value) use (&$done) : void{
|
||||
$done = true;
|
||||
self::assertEquals([1], $value);
|
||||
},
|
||||
function() use (&$done) : void{
|
||||
$done = true;
|
||||
self::fail("Promise was rejected");
|
||||
}
|
||||
);
|
||||
self::assertFalse($done);
|
||||
$resolver->resolve(1);
|
||||
self::assertTrue($done);
|
||||
}
|
||||
|
||||
public function testAllResolve() : void{
|
||||
$resolver1 = new PromiseResolver();
|
||||
$resolver2 = new PromiseResolver();
|
||||
|
||||
$allPromise = Promise::all([$resolver1->getPromise(), $resolver2->getPromise()]);
|
||||
$done = false;
|
||||
$allPromise->onCompletion(
|
||||
function($value) use (&$done) : void{
|
||||
$done = true;
|
||||
self::assertEquals([1, 2], $value);
|
||||
},
|
||||
function() use (&$done) : void{
|
||||
$done = true;
|
||||
self::fail("Promise was rejected");
|
||||
}
|
||||
);
|
||||
self::assertFalse($done);
|
||||
$resolver1->resolve(1);
|
||||
self::assertFalse($done);
|
||||
$resolver2->resolve(2);
|
||||
self::assertTrue($done);
|
||||
}
|
||||
|
||||
public function testAllPartialReject() : void{
|
||||
$resolver1 = new PromiseResolver();
|
||||
$resolver2 = new PromiseResolver();
|
||||
|
||||
$allPromise = Promise::all([$resolver1->getPromise(), $resolver2->getPromise()]);
|
||||
$done = false;
|
||||
$allPromise->onCompletion(
|
||||
function($value) use (&$done) : void{
|
||||
$done = true;
|
||||
self::fail("Promise was unexpectedly resolved");
|
||||
},
|
||||
function() use (&$done) : void{
|
||||
$done = true;
|
||||
}
|
||||
);
|
||||
self::assertFalse($done);
|
||||
$resolver2->reject();
|
||||
self::assertTrue($done, "All promise should be rejected immediately after the first constituent rejection");
|
||||
$resolver1->resolve(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Promise::all() should return a rejected promise if any of the input promises were rejected at the call time
|
||||
*/
|
||||
public function testAllPartialPreReject() : void{
|
||||
$resolver1 = new PromiseResolver();
|
||||
$resolver2 = new PromiseResolver();
|
||||
$resolver2->reject();
|
||||
|
||||
$allPromise = Promise::all([$resolver1->getPromise(), $resolver2->getPromise()]);
|
||||
$done = false;
|
||||
$allPromise->onCompletion(
|
||||
function($value) use (&$done) : void{
|
||||
$done = true;
|
||||
self::fail("Promise was unexpectedly resolved");
|
||||
},
|
||||
function() use (&$done) : void{
|
||||
$done = true;
|
||||
}
|
||||
);
|
||||
self::assertTrue($done, "All promise should be rejected immediately after the first constituent rejection");
|
||||
$resolver1->resolve(1);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user