PHP code example of uru / testhub-bundle

1. Go to this page and download the library: Download uru/testhub-bundle 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/ */

    

uru / testhub-bundle example snippets


return [
    // ...
    TestHub\Bundle\TestHubBundle::class => ['dev' => true],
];

   use TestHub\Bundle\Service\SandBoxService;

   $httpClient->request('GET', 'https://psp.example/balance', [
       'extra' => [SandBoxService::SANDBOX_TYPE => 'balance'],
   ]);
   

namespace App\Sandbox;

use TestHub\Bundle\HttpClient\State\ContextProviderInterface;

final class CurrentAgentProvider implements ContextProviderInterface
{
    public function __construct(private AgentRepository $agents) {}

    public function get(): array
    {
        return [$this->agents->current()];
    }
}

namespace App\Sandbox;

use TestHub\Bundle\Action\ActionInterface;

final class CheckStatusAction implements ActionInterface
{
    public function getName(): string { return 'check_status'; }
    public function getLabel(): string { return 'Check status'; }
    public function getDescription(): string { return 'Asks the provider for the status of an order.'; }

    /** Form fields, as name => label. */
    public function getParameters(): array
    {
        return ['order_id' => 'Order ID'];
    }

    public function run(array $parameters): string
    {
        // ...
        return 'Status checked.';
    }
}

namespace App\Development\TestHub;

use TestHub\Bundle\Action\PayoutRunnerInterface;

final class PayoutRunner implements PayoutRunnerInterface
{
    public function payout(string $provider, string $gateway, int $refId): void
    {
        // Start the payout for the gateway, as the payout cron does.
        // Throw an exception to show the run as failed.
    }
}
bash
php bin/console test-hub:install -n --context-provider='App\Sandbox\CurrentAgentProvider' --sandbox-url=https://sandbox.example.com --api-key=your-key
bash
php bin/console test-hub:docker-host            # asks which service
php bin/console test-hub:docker-host php        # result:
yaml
services:
    php:
        # ...
        extra_hosts:
            - "sandbox.lan:host-gateway"