Skip to content

The docs example test is left waiting indefinitely #23

Open
@ghost

Description

👋 Hi there,

At ChesslaBlab we're writing functional tests for the PHP Chess Server.

See:

At this moment I'm trying to run the docs example as it is shown in the two images below.

tab_01
Figure 1. php cli/testing.php

tab_02
Figure 2. vendor/bin/phpunit tests/functional/

However, the test is left waiting indefinitely.

<?php

namespace ChessServer\Tests\Functional;

use Amp\ByteStream;
use Amp\PHPUnit\AsyncTestCase;
use Amp\Socket;

class StartCommandTest extends AsyncTestCase
{
    public function test(): void
    {
        $socket = Socket\connect('tcp://127.0.0.1:8080');
        
        $socket->write('/start classical fen');

        $expected = '{"\/start":{"variant":"classical","mode":"fen","fen":"rnbqkbnr\/pppppppp\/8\/8\/8\/8\/PPPPPPPP\/RNBQKBNR w KQkq -"}}';

        $this->assertSame($expected, ByteStream\buffer($socket));
    }
}

Also this is the cli/testing.php script running the TCP socket server on port 8080 shown in Figure 1.

<?php

namespace ChessServer\Cli;

use ChessServer\Socket\TcpSocket;
use Dotenv\Dotenv;

require __DIR__ . '/../vendor/autoload.php';

$dotenv = Dotenv::createImmutable(__DIR__.'/../');
$dotenv->load();

$server = new TcpSocket($_ENV['TCP_PORT']);

Any help would be greatly appreciated.

Thank you,

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions