friendsofhyperf/pest-plugin-hyperf

The Pest Hyperf Plugin.

v3.1.41 2024-09-25 00:28 UTC

README

Latest Stable Version Total Downloads License

This is a Pest plugin that enables your Hyperf project's Pest to run within a Swoole-based coroutine environment.

Installation

composer require friendsofhyperf/pest-plugin-hyperf --dev

Usage

php vendor/bin/pest --coroutine
# or
php vendor/bin/pest --prepend test/prepend.php --coroutine
  • test/prepend.php
<?php
require_once __DIR__ . '/../vendor/autoload.php';

defined('BASE_PATH') or define('BASE_PATH', dirname(__DIR__, 1));

(function () {
    \Hyperf\Di\ClassLoader::init();

    \Hyperf\Context\ApplicationContext::setContainer(
        new \Hyperf\Di\Container((new \Hyperf\Di\Definition\DefinitionSourceFactory())())
    );
    
    // $container->get(Hyperf\Contract\ApplicationInterface::class);
})();

Contact

License

MIT