Merge branch 'stable'

This commit is contained in:
Dylan K. Taylor
2020-02-07 18:13:55 +00:00
88 changed files with 543 additions and 283 deletions

View File

@ -64,7 +64,7 @@ class BlockTest extends TestCase{
}
}
self::assertTrue(false, "Can't test registering new blocks because no unused spaces left");
throw new \RuntimeException("Can't test registering new blocks because no unused spaces left");
}
/**
@ -97,7 +97,8 @@ class BlockTest extends TestCase{
}
/**
* @return array
* @return int[][]
* @phpstan-return list<array{int,int}>
*/
public function blockGetProvider() : array{
return [

View File

@ -29,7 +29,7 @@ use pocketmine\item\ItemIds;
class BaseInventoryTest extends TestCase{
public static function setUpBeforeClass(){
public static function setUpBeforeClass() : void{
ItemFactory::init();
}

View File

@ -42,6 +42,10 @@ class ItemFactoryTest extends TestCase{
}
}
/**
* @return mixed[][]
* @phpstan-return list<array{string,int,int}>
*/
public function itemFromStringProvider() : array{
return [
["dye:4", ItemIds::DYE, 4],

View File

@ -33,6 +33,10 @@ class StupidJsonDecodeTest extends TestCase{
$this->stupidJsonDecodeFunc = (new \ReflectionMethod(InGamePacketHandler::class, 'stupid_json_decode'))->getClosure();
}
/**
* @return mixed[][]
* @phpstan-return list<array{string,mixed}>
*/
public function stupidJsonDecodeProvider() : array{
return [
["[\n \"a\",\"b,c,d,e\\\" \",,0,1,2, false, 0.001]", ['a', 'b,c,d,e" ', '', 0, 1, 2, false, 0.001]],
@ -55,7 +59,7 @@ class StupidJsonDecodeTest extends TestCase{
*
* @throws \ReflectionException
*/
public function testStupidJsonDecode(string $brokenJson, $expect){
public function testStupidJsonDecode(string $brokenJson, $expect) : void{
$decoded = ($this->stupidJsonDecodeFunc)($brokenJson, true);
self::assertEquals($expect, $decoded);
}

View File

@ -28,7 +28,8 @@ use PHPUnit\Framework\TestCase;
class ConfigTest extends TestCase{
/**
* @return \Generator
* @return \Generator|mixed[][]
* @phpstan-return \Generator<int, array{string, mixed[]}, void, void>
*/
public function fixYamlIndexesProvider() : \Generator{
yield ["x: 1\ny: 2\nz: 3\n", [
@ -60,8 +61,8 @@ class ConfigTest extends TestCase{
/**
* @dataProvider fixYamlIndexesProvider
*
* @param string $test
* @param array $expected
* @param string $test
* @param mixed[] $expected
*/
public function testFixYamlIndexes(string $test, array $expected) : void{
$fixed = Config::fixYAMLIndexes($test);

View File

@ -29,7 +29,7 @@ use function defined;
class UtilsTest extends TestCase{
public function setUp(){
public function setUp() : void{
if(!defined('pocketmine\PATH')){
define('pocketmine\PATH', 'dummy');
}
@ -38,6 +38,10 @@ class UtilsTest extends TestCase{
}
}
/**
* @return string[][]
* @phpstan-return list<array{string}>
*/
public function parseDocCommentNewlineProvider() : array{
return [
["\t/**\r\n\t * @param PlayerJoinEvent \$event\r\n\t * @priority HIGHEST\r\n\t * @notHandler\r\n\t */"],
@ -61,6 +65,6 @@ class UtilsTest extends TestCase{
public function testNamespacedNiceClosureName() : void{
//be careful with this test. The closure has to be declared on the same line as the assertion.
self::assertSame('closure@' . Filesystem::cleanPath(__FILE__) . '#L' . __LINE__, Utils::getNiceClosureName(function(){}));
self::assertSame('closure@' . Filesystem::cleanPath(__FILE__) . '#L' . __LINE__, Utils::getNiceClosureName(function() : void{}));
}
}

View File

@ -38,7 +38,7 @@ class RegionLoaderTest extends TestCase{
/** @var RegionLoader */
private $region;
public function setUp(){
public function setUp() : void{
$this->regionPath = sys_get_temp_dir() . '/test.testregion';
if(file_exists($this->regionPath)){
unlink($this->regionPath);
@ -47,7 +47,7 @@ class RegionLoaderTest extends TestCase{
$this->region->open();
}
public function tearDown(){
public function tearDown() : void{
$this->region->close();
if(file_exists($this->regionPath)){
unlink($this->regionPath);
@ -69,6 +69,10 @@ class RegionLoaderTest extends TestCase{
self::assertSame($data, $r->readChunk(0, 0));
}
/**
* @return \Generator|int[][]
* @phpstan-return \Generator<int, array{int,int}, void, void>
*/
public function outOfBoundsCoordsProvider() : \Generator{
yield [-1, -1];
yield [32, 32];