mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-16 00:15:35 +00:00
PHPUnit migrated to attributes :(
This commit is contained in:
parent
6b5ff5016e
commit
9e773ed439
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use pocketmine\block\utils\BrewingStandSlot;
|
use pocketmine\block\utils\BrewingStandSlot;
|
||||||
use function count;
|
use function count;
|
||||||
@ -39,11 +40,10 @@ class BrewingStandTest extends TestCase{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider slotsProvider
|
|
||||||
*
|
|
||||||
* @param BrewingStandSlot[] $slots
|
* @param BrewingStandSlot[] $slots
|
||||||
* @phpstan-param list<BrewingStandSlot> $slots
|
* @phpstan-param list<BrewingStandSlot> $slots
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider("slotsProvider")]
|
||||||
public function testHasAndSetSlot(array $slots) : void{
|
public function testHasAndSetSlot(array $slots) : void{
|
||||||
$block = VanillaBlocks::BREWING_STAND();
|
$block = VanillaBlocks::BREWING_STAND();
|
||||||
foreach($slots as $slot){
|
foreach($slots as $slot){
|
||||||
@ -62,11 +62,10 @@ class BrewingStandTest extends TestCase{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider slotsProvider
|
|
||||||
*
|
|
||||||
* @param BrewingStandSlot[] $slots
|
* @param BrewingStandSlot[] $slots
|
||||||
* @phpstan-param list<BrewingStandSlot> $slots
|
* @phpstan-param list<BrewingStandSlot> $slots
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider("slotsProvider")]
|
||||||
public function testGetSlots(array $slots) : void{
|
public function testGetSlots(array $slots) : void{
|
||||||
$block = VanillaBlocks::BREWING_STAND();
|
$block = VanillaBlocks::BREWING_STAND();
|
||||||
|
|
||||||
@ -83,11 +82,10 @@ class BrewingStandTest extends TestCase{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider slotsProvider
|
|
||||||
*
|
|
||||||
* @param BrewingStandSlot[] $slots
|
* @param BrewingStandSlot[] $slots
|
||||||
* @phpstan-param list<BrewingStandSlot> $slots
|
* @phpstan-param list<BrewingStandSlot> $slots
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider("slotsProvider")]
|
||||||
public function testSetSlots(array $slots) : void{
|
public function testSetSlots(array $slots) : void{
|
||||||
$block = VanillaBlocks::BREWING_STAND();
|
$block = VanillaBlocks::BREWING_STAND();
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\command\utils;
|
namespace pocketmine\command\utils;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class CommandStringHelperTest extends TestCase{
|
class CommandStringHelperTest extends TestCase{
|
||||||
@ -47,9 +48,9 @@ class CommandStringHelperTest extends TestCase{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider parseQuoteAwareProvider
|
|
||||||
* @param string[] $expected
|
* @param string[] $expected
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider("parseQuoteAwareProvider")]
|
||||||
public function testParseQuoteAware(string $commandLine, array $expected) : void{
|
public function testParseQuoteAware(string $commandLine, array $expected) : void{
|
||||||
$actual = CommandStringHelper::parseQuoteAware($commandLine);
|
$actual = CommandStringHelper::parseQuoteAware($commandLine);
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\console;
|
namespace pocketmine\console;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use function mt_rand;
|
use function mt_rand;
|
||||||
use function str_repeat;
|
use function str_repeat;
|
||||||
@ -40,9 +41,7 @@ final class ConsoleReaderChildProcessUtilsTest extends TestCase{
|
|||||||
yield ["give \"Steve\" golden_apple"];
|
yield ["give \"Steve\" golden_apple"];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider("commandStringProvider")]
|
||||||
* @dataProvider commandStringProvider
|
|
||||||
*/
|
|
||||||
public function testCreateParseSymmetry(string $input) : void{
|
public function testCreateParseSymmetry(string $input) : void{
|
||||||
$counterCreate = $counterParse = mt_rand();
|
$counterCreate = $counterParse = mt_rand();
|
||||||
$message = ConsoleReaderChildProcessUtils::createMessage($input, $counterCreate);
|
$message = ConsoleReaderChildProcessUtils::createMessage($input, $counterCreate);
|
||||||
@ -74,9 +73,7 @@ final class ConsoleReaderChildProcessUtilsTest extends TestCase{
|
|||||||
yield ["a" . ConsoleReaderChildProcessUtils::TOKEN_DELIMITER . "b", false]; //message with delimiter but not a valid IPC message
|
yield ["a" . ConsoleReaderChildProcessUtils::TOKEN_DELIMITER . "b", false]; //message with delimiter but not a valid IPC message
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider("parseMessageProvider")]
|
||||||
* @dataProvider parseMessageProvider
|
|
||||||
*/
|
|
||||||
public static function testParseMessage(string $message, bool $valid) : void{
|
public static function testParseMessage(string $message, bool $valid) : void{
|
||||||
$counter = $oldCounter = 0;
|
$counter = $oldCounter = 0;
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\data\bedrock\block\upgrade;
|
namespace pocketmine\data\bedrock\block\upgrade;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\data\bedrock\block\BlockStateData;
|
use pocketmine\data\bedrock\block\BlockStateData;
|
||||||
@ -126,9 +127,9 @@ class BlockStateUpgraderTest extends TestCase{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider removePropertyProvider
|
|
||||||
* @phpstan-param \Closure() : BlockStateData $getStateData
|
* @phpstan-param \Closure() : BlockStateData $getStateData
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider("removePropertyProvider")]
|
||||||
public function testRemoveProperty(\Closure $getStateData) : void{
|
public function testRemoveProperty(\Closure $getStateData) : void{
|
||||||
$this->prepareRemovePropertySchema($this->getNewSchema());
|
$this->prepareRemovePropertySchema($this->getNewSchema());
|
||||||
|
|
||||||
@ -151,9 +152,9 @@ class BlockStateUpgraderTest extends TestCase{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider renamePropertyProvider
|
|
||||||
* @phpstan-param \Closure() : BlockStateData $getStateData
|
* @phpstan-param \Closure() : BlockStateData $getStateData
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider("renamePropertyProvider")]
|
||||||
public function testRenameProperty(\Closure $getStateData, ?int $valueAfter) : void{
|
public function testRenameProperty(\Closure $getStateData, ?int $valueAfter) : void{
|
||||||
$this->prepareRenamePropertySchema($this->getNewSchema());
|
$this->prepareRenamePropertySchema($this->getNewSchema());
|
||||||
|
|
||||||
@ -187,9 +188,9 @@ class BlockStateUpgraderTest extends TestCase{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider remapPropertyValueProvider
|
|
||||||
* @phpstan-param \Closure() : BlockStateData $getStateData
|
* @phpstan-param \Closure() : BlockStateData $getStateData
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider("remapPropertyValueProvider")]
|
||||||
public function testRemapPropertyValue(\Closure $getStateData, ?int $valueAfter) : void{
|
public function testRemapPropertyValue(\Closure $getStateData, ?int $valueAfter) : void{
|
||||||
$this->prepareRemapPropertyValueSchema($this->getNewSchema());
|
$this->prepareRemapPropertyValueSchema($this->getNewSchema());
|
||||||
|
|
||||||
@ -199,9 +200,9 @@ class BlockStateUpgraderTest extends TestCase{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider remapPropertyValueProvider
|
|
||||||
* @phpstan-param \Closure() : BlockStateData $getStateData
|
* @phpstan-param \Closure() : BlockStateData $getStateData
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider("remapPropertyValueProvider")]
|
||||||
public function testRemapAndRenameProperty(\Closure $getStateData, ?int $valueAfter) : void{
|
public function testRemapAndRenameProperty(\Closure $getStateData, ?int $valueAfter) : void{
|
||||||
$schema = $this->getNewSchema();
|
$schema = $this->getNewSchema();
|
||||||
$this->prepareRenamePropertySchema($schema);
|
$this->prepareRenamePropertySchema($schema);
|
||||||
@ -239,9 +240,7 @@ class BlockStateUpgraderTest extends TestCase{
|
|||||||
yield [0x1_00_00_00, 0x1_00_01_00, false, 1]; //Block newer than schema: block must NOT be altered
|
yield [0x1_00_00_00, 0x1_00_01_00, false, 1]; //Block newer than schema: block must NOT be altered
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider("upgraderVersionCompatibilityProvider")]
|
||||||
* @dataProvider upgraderVersionCompatibilityProvider
|
|
||||||
*/
|
|
||||||
public function testUpgraderVersionCompatibility(int $schemaVersion, int $stateVersion, bool $shouldChange, int $schemaCount) : void{
|
public function testUpgraderVersionCompatibility(int $schemaVersion, int $stateVersion, bool $shouldChange, int $schemaCount) : void{
|
||||||
for($i = 0; $i < $schemaCount; $i++){
|
for($i = 0; $i < $schemaCount; $i++){
|
||||||
$schema = $this->getNewSchemaVersion($schemaVersion, $i);
|
$schema = $this->getNewSchemaVersion($schemaVersion, $i);
|
||||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\event;
|
namespace pocketmine\event;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use pocketmine\event\fixtures\TestAbstractAllowHandleEvent;
|
use pocketmine\event\fixtures\TestAbstractAllowHandleEvent;
|
||||||
use pocketmine\event\fixtures\TestAbstractEvent;
|
use pocketmine\event\fixtures\TestAbstractEvent;
|
||||||
@ -63,10 +64,9 @@ class HandlerListManagerTest extends TestCase{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider isValidClassProvider
|
|
||||||
*
|
|
||||||
* @phpstan-param \ReflectionClass<Event> $class
|
* @phpstan-param \ReflectionClass<Event> $class
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider("isValidClassProvider")]
|
||||||
public function testIsValidClass(\ReflectionClass $class, bool $isValid, string $reason) : void{
|
public function testIsValidClass(\ReflectionClass $class, bool $isValid, string $reason) : void{
|
||||||
self::assertSame($isValid, ($this->isValidFunc)($class), $reason);
|
self::assertSame($isValid, ($this->isValidFunc)($class), $reason);
|
||||||
}
|
}
|
||||||
@ -83,11 +83,10 @@ class HandlerListManagerTest extends TestCase{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider resolveParentClassProvider
|
|
||||||
*
|
|
||||||
* @phpstan-param \ReflectionClass<Event> $class
|
* @phpstan-param \ReflectionClass<Event> $class
|
||||||
* @phpstan-param \ReflectionClass<Event>|null $expect
|
* @phpstan-param \ReflectionClass<Event>|null $expect
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider("resolveParentClassProvider")]
|
||||||
public function testResolveParentClass(\ReflectionClass $class, ?\ReflectionClass $expect) : void{
|
public function testResolveParentClass(\ReflectionClass $class, ?\ReflectionClass $expect) : void{
|
||||||
if($expect === null){
|
if($expect === null){
|
||||||
self::assertNull(($this->resolveParentFunc)($class));
|
self::assertNull(($this->resolveParentFunc)($class));
|
||||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\item;
|
namespace pocketmine\item;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use pocketmine\block\VanillaBlocks;
|
use pocketmine\block\VanillaBlocks;
|
||||||
|
|
||||||
@ -43,9 +44,7 @@ class LegacyStringToItemParserTest extends TestCase{
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider("itemFromStringProvider")]
|
||||||
* @dataProvider itemFromStringProvider
|
|
||||||
*/
|
|
||||||
public function testFromStringSingle(string $string, Item $expected) : void{
|
public function testFromStringSingle(string $string, Item $expected) : void{
|
||||||
$item = LegacyStringToItemParser::getInstance()->parse($string);
|
$item = LegacyStringToItemParser::getInstance()->parse($string);
|
||||||
|
|
||||||
|
@ -23,14 +23,13 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\network\mcpe\convert;
|
namespace pocketmine\network\mcpe\convert;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use pocketmine\block\RuntimeBlockStateRegistry;
|
use pocketmine\block\RuntimeBlockStateRegistry;
|
||||||
|
|
||||||
class BlockTranslatorTest extends TestCase{
|
class BlockTranslatorTest extends TestCase{
|
||||||
|
|
||||||
/**
|
#[DoesNotPerformAssertions]
|
||||||
* @doesNotPerformAssertions
|
|
||||||
*/
|
|
||||||
public function testAllBlockStatesSerialize() : void{
|
public function testAllBlockStatesSerialize() : void{
|
||||||
$blockTranslator = TypeConverter::getInstance()->getBlockTranslator();
|
$blockTranslator = TypeConverter::getInstance()->getBlockTranslator();
|
||||||
foreach(RuntimeBlockStateRegistry::getInstance()->getAllKnownStates() as $state){
|
foreach(RuntimeBlockStateRegistry::getInstance()->getAllKnownStates() as $state){
|
||||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\plugin;
|
namespace pocketmine\plugin;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use function sort;
|
use function sort;
|
||||||
|
|
||||||
@ -47,9 +48,7 @@ class ApiVersionTest extends TestCase{
|
|||||||
yield ["3.0.0-ALPHA1", "4.0.0-ALPHA1", false];
|
yield ["3.0.0-ALPHA1", "4.0.0-ALPHA1", false];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider("compatibleApiProvider")]
|
||||||
* @dataProvider compatibleApiProvider
|
|
||||||
*/
|
|
||||||
public function testCompatibleApi(string $myVersion, string $wantVersion, bool $expected) : void{
|
public function testCompatibleApi(string $myVersion, string $wantVersion, bool $expected) : void{
|
||||||
self::assertSame($expected, ApiVersion::isCompatible($myVersion, [$wantVersion]), "my version: $myVersion, their version: $wantVersion, expect " . ($expected ? "yes" : "no"));
|
self::assertSame($expected, ApiVersion::isCompatible($myVersion, [$wantVersion]), "my version: $myVersion, their version: $wantVersion, expect " . ($expected ? "yes" : "no"));
|
||||||
}
|
}
|
||||||
@ -67,11 +66,10 @@ class ApiVersionTest extends TestCase{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider ambiguousVersionsProvider
|
|
||||||
*
|
|
||||||
* @param string[] $input
|
* @param string[] $input
|
||||||
* @param string[] $expectedOutput
|
* @param string[] $expectedOutput
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider("ambiguousVersionsProvider")]
|
||||||
public function testFindAmbiguousVersions(array $input, array $expectedOutput) : void{
|
public function testFindAmbiguousVersions(array $input, array $expectedOutput) : void{
|
||||||
$ambiguous = ApiVersion::checkAmbiguousVersions($input);
|
$ambiguous = ApiVersion::checkAmbiguousVersions($input);
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\scheduler;
|
namespace pocketmine\scheduler;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use pmmp\thread\ThreadSafeArray;
|
use pmmp\thread\ThreadSafeArray;
|
||||||
use pocketmine\promise\PromiseResolver;
|
use pocketmine\promise\PromiseResolver;
|
||||||
@ -84,9 +85,8 @@ class AsyncPoolTest extends TestCase{
|
|||||||
*
|
*
|
||||||
* Due to an unset() in the function body, other AsyncTask::__destruct() calls could be triggered during
|
* Due to an unset() in the function body, other AsyncTask::__destruct() calls could be triggered during
|
||||||
* an AsyncTask's destruction. If done in the wrong way, this could lead to a crash.
|
* an AsyncTask's destruction. If done in the wrong way, this could lead to a crash.
|
||||||
*
|
|
||||||
* @doesNotPerformAssertions This test is checking for a crash condition, not a specific output.
|
|
||||||
*/
|
*/
|
||||||
|
#[DoesNotPerformAssertions]
|
||||||
public function testTaskDestructorReentrancy() : void{
|
public function testTaskDestructorReentrancy() : void{
|
||||||
$this->pool->submitTask(new class extends AsyncTask{
|
$this->pool->submitTask(new class extends AsyncTask{
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\utils;
|
namespace pocketmine\utils;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
final class CloningRegistryTraitTest extends TestCase{
|
final class CloningRegistryTraitTest extends TestCase{
|
||||||
@ -37,9 +38,9 @@ final class CloningRegistryTraitTest extends TestCase{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider cloningRegistryMembersProvider
|
|
||||||
* @phpstan-param \Closure() : \stdClass $provider
|
* @phpstan-param \Closure() : \stdClass $provider
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider("cloningRegistryMembersProvider")]
|
||||||
public function testEachMemberClone(\Closure $provider) : void{
|
public function testEachMemberClone(\Closure $provider) : void{
|
||||||
self::assertNotSame($provider(), $provider(), "Cloning registry should never return the same object twice");
|
self::assertNotSame($provider(), $provider(), "Cloning registry should never return the same object twice");
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\utils;
|
namespace pocketmine\utils;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use function yaml_parse;
|
use function yaml_parse;
|
||||||
|
|
||||||
@ -60,10 +61,9 @@ class ConfigTest extends TestCase{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider fixYamlIndexesProvider
|
|
||||||
*
|
|
||||||
* @param mixed[] $expected
|
* @param mixed[] $expected
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider("fixYamlIndexesProvider")]
|
||||||
public function testFixYamlIndexes(string $test, array $expected) : void{
|
public function testFixYamlIndexes(string $test, array $expected) : void{
|
||||||
$fixed = Config::fixYAMLIndexes($test);
|
$fixed = Config::fixYAMLIndexes($test);
|
||||||
$decoded = yaml_parse($fixed);
|
$decoded = yaml_parse($fixed);
|
||||||
|
@ -23,6 +23,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\utils;
|
namespace pocketmine\utils;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
|
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use pocketmine\utils\fixtures\TestAbstractClass;
|
use pocketmine\utils\fixtures\TestAbstractClass;
|
||||||
use pocketmine\utils\fixtures\TestInstantiableClass;
|
use pocketmine\utils\fixtures\TestInstantiableClass;
|
||||||
@ -52,9 +54,7 @@ class UtilsTest extends TestCase{
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider("parseDocCommentNewlineProvider")]
|
||||||
* @dataProvider parseDocCommentNewlineProvider
|
|
||||||
*/
|
|
||||||
public function testParseDocCommentNewlines(string $docComment) : void{
|
public function testParseDocCommentNewlines(string $docComment) : void{
|
||||||
$tags = Utils::parseDocComment($docComment);
|
$tags = Utils::parseDocComment($docComment);
|
||||||
|
|
||||||
@ -76,9 +76,7 @@ class UtilsTest extends TestCase{
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider("parseDocCommentOneLineProvider")]
|
||||||
* @dataProvider parseDocCommentOneLineProvider
|
|
||||||
*/
|
|
||||||
public function testParseOneLineDocComment(string $comment) : void{
|
public function testParseOneLineDocComment(string $comment) : void{
|
||||||
$tags = Utils::parseDocComment($comment);
|
$tags = Utils::parseDocComment($comment);
|
||||||
self::assertArrayHasKey("ignoreCancelled", $tags);
|
self::assertArrayHasKey("ignoreCancelled", $tags);
|
||||||
@ -120,11 +118,11 @@ class UtilsTest extends TestCase{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider validInstanceProvider
|
|
||||||
* @doesNotPerformAssertions
|
|
||||||
* @phpstan-param class-string $className
|
* @phpstan-param class-string $className
|
||||||
* @phpstan-param class-string $baseName
|
* @phpstan-param class-string $baseName
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider("validInstanceProvider")]
|
||||||
|
#[DoesNotPerformAssertions]
|
||||||
public function testValidInstanceWithValidCombinations(string $className, string $baseName) : void{
|
public function testValidInstanceWithValidCombinations(string $className, string $baseName) : void{
|
||||||
Utils::testValidInstance($className, $baseName);
|
Utils::testValidInstance($className, $baseName);
|
||||||
}
|
}
|
||||||
@ -146,9 +144,7 @@ class UtilsTest extends TestCase{
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider("validInstanceInvalidCombinationsProvider")]
|
||||||
* @dataProvider validInstanceInvalidCombinationsProvider
|
|
||||||
*/
|
|
||||||
public function testValidInstanceInvalidParameters(string $className, string $baseName) : void{
|
public function testValidInstanceInvalidParameters(string $className, string $baseName) : void{
|
||||||
$this->expectException(\InvalidArgumentException::class);
|
$this->expectException(\InvalidArgumentException::class);
|
||||||
Utils::testValidInstance($className, $baseName); //@phpstan-ignore-line
|
Utils::testValidInstance($className, $baseName); //@phpstan-ignore-line
|
||||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\world\format\io\region;
|
namespace pocketmine\world\format\io\region;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use pocketmine\world\format\ChunkException;
|
use pocketmine\world\format\ChunkException;
|
||||||
use Symfony\Component\Filesystem\Path;
|
use Symfony\Component\Filesystem\Path;
|
||||||
@ -82,11 +83,10 @@ class RegionLoaderTest extends TestCase{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider outOfBoundsCoordsProvider
|
|
||||||
*
|
|
||||||
* @throws ChunkException
|
* @throws ChunkException
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider("outOfBoundsCoordsProvider")]
|
||||||
public function testWriteChunkOutOfBounds(int $x, int $z) : void{
|
public function testWriteChunkOutOfBounds(int $x, int $z) : void{
|
||||||
$this->expectException(\InvalidArgumentException::class);
|
$this->expectException(\InvalidArgumentException::class);
|
||||||
$this->region->writeChunk($x, $z, str_repeat("\x00", 1000));
|
$this->region->writeChunk($x, $z, str_repeat("\x00", 1000));
|
||||||
@ -107,11 +107,10 @@ class RegionLoaderTest extends TestCase{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider outOfBoundsCoordsProvider
|
|
||||||
*
|
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
* @throws \pocketmine\world\format\io\exception\CorruptedChunkException
|
* @throws \pocketmine\world\format\io\exception\CorruptedChunkException
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider("outOfBoundsCoordsProvider")]
|
||||||
public function testReadChunkOutOfBounds(int $x, int $z) : void{
|
public function testReadChunkOutOfBounds(int $x, int $z) : void{
|
||||||
$this->expectException(\InvalidArgumentException::class);
|
$this->expectException(\InvalidArgumentException::class);
|
||||||
$this->region->readChunk($x, $z);
|
$this->region->readChunk($x, $z);
|
||||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\world\format\io\region;
|
namespace pocketmine\world\format\io\region;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use function sprintf;
|
use function sprintf;
|
||||||
|
|
||||||
@ -40,9 +41,7 @@ class RegionLocationTableEntryTest extends TestCase{
|
|||||||
yield [new RegionLocationTableEntry(2, 4, 0), new RegionLocationTableEntry(3, 1, 0), true];
|
yield [new RegionLocationTableEntry(2, 4, 0), new RegionLocationTableEntry(3, 1, 0), true];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider("overlapDataProvider")]
|
||||||
* @dataProvider overlapDataProvider
|
|
||||||
*/
|
|
||||||
public function testOverlap(RegionLocationTableEntry $entry1, RegionLocationTableEntry $entry2, bool $overlaps) : void{
|
public function testOverlap(RegionLocationTableEntry $entry1, RegionLocationTableEntry $entry2, bool $overlaps) : void{
|
||||||
$stringify = function(RegionLocationTableEntry $entry) : string{
|
$stringify = function(RegionLocationTableEntry $entry) : string{
|
||||||
return sprintf("entry first=%d last=%d size=%d", $entry->getFirstSector(), $entry->getLastSector(), $entry->getSectorCount());
|
return sprintf("entry first=%d last=%d size=%d", $entry->getFirstSector(), $entry->getLastSector(), $entry->getSectorCount());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user