定制 refaltor/pest-pmmp-tests 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

refaltor/pest-pmmp-tests

最新稳定版本:2.1.0

Composer 安装命令:

composer require refaltor/pest-pmmp-tests

包简介

Little library for create unit test in PocketMine with Await Generator.

README 文档

README

Logo

Pest PMMP Tests

License PHP PocketMine-MP Await Generator

Simple & elegant unit testing for PocketMine-MP inspired by Pest and powered Await Generator.

📦 Installation

composer require refaltor/pest-pmmp-tests

📦 Simple Usage

In your PocketMine plugin, you can easily integrate this unit testing library and run it either through a command or directly in onEnable — it’s totally up to you.

 public function onEnable(): void
 {
     # tester load
     PocketMineTester::initPlugin($this);
     PocketMineTester::launchTest(__DIR__ . '/tests', "core\\tests\\");
 }

Project Structure Example :

my-plugin/
├── src/
│   └── core/
│       └── Main.php
├── tests/
│   └── MyFirstTest.php
├── plugin.yml
├── composer.json
└── README.md

📦 Test Example

Note: For your tests to run, your .php file must end with ...Test.php, and all the functions within that file must end with ...test().

<?php

namespace core\tests;

use core\Main;
use Generator;
use Refaltor\PestPmmpTests\tests\PmmpTest;
use SOFe\AwaitGenerator\Await;

class TestTest extends PmmpTest
{
    public function player_check_name_test(): Generator
    {
        $player = $this->getFakePlayer();
        
        $this->assertString("FAKEPLAYER", $player->getName());

        return yield Await::ALL;
    }

    public function player_check_name_error_test(): Generator
    {
        $player = $this->getFakePlayer();

        $this->assertString("FAKEPLAYERRRRRR", $player->getName());

        return yield Await::ALL;
    }

    public function onBeforeAllTest(): void
    {
        Main::getInstance()->getLogger()->info("Units test is starting...");
    }

    public function onAfterAllTest(): void
    {
        Main::getInstance()->getLogger()->info("Units test is finish.");
    }
}

Result :

Result

统计信息

  • 总下载量: 13
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-10