PHP code example of refaltor / pest-pmmp-tests

1. Go to this page and download the library: Download refaltor/pest-pmmp-tests library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

refaltor / pest-pmmp-tests example snippets


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



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.");
    }
}

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