mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-04 09:10:00 +00:00
StupidJsonDecodeTest: use getClosure() instead of traditional mess
this is faster and requires less code.
This commit is contained in:
parent
7a2a4e2aa3
commit
d0d61597c7
@ -26,6 +26,12 @@ namespace pocketmine\network\mcpe;
|
|||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class StupidJsonDecodeTest extends TestCase{
|
class StupidJsonDecodeTest extends TestCase{
|
||||||
|
/** @var \Closure */
|
||||||
|
private $stupidJsonDecodeFunc;
|
||||||
|
|
||||||
|
public function setUp() : void{
|
||||||
|
$this->stupidJsonDecodeFunc = (new \ReflectionMethod(PlayerNetworkSessionAdapter::class, 'stupid_json_decode'))->getClosure();
|
||||||
|
}
|
||||||
|
|
||||||
public function stupidJsonDecodeProvider() : array{
|
public function stupidJsonDecodeProvider() : array{
|
||||||
return [
|
return [
|
||||||
@ -48,10 +54,7 @@ class StupidJsonDecodeTest extends TestCase{
|
|||||||
* @throws \ReflectionException
|
* @throws \ReflectionException
|
||||||
*/
|
*/
|
||||||
public function testStupidJsonDecode(string $brokenJson, $expect){
|
public function testStupidJsonDecode(string $brokenJson, $expect){
|
||||||
$func = new \ReflectionMethod(PlayerNetworkSessionAdapter::class, 'stupid_json_decode');
|
$decoded = ($this->stupidJsonDecodeFunc)($brokenJson, true);
|
||||||
$func->setAccessible(true);
|
|
||||||
|
|
||||||
$decoded = $func->invoke(null, $brokenJson, true);
|
|
||||||
self::assertEquals($expect, $decoded);
|
self::assertEquals($expect, $decoded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user