|
48 | 48 | $dispatcher = Mockery::mock(EventDispatcherInterface::class); |
49 | 49 | $loop = Mockery::mock(LoopInterface::class); |
50 | 50 | $idGen = new MessageIdGenerator('test-'); |
51 | | - $server1 = new ServerConfig(name: 's1', transport: TransportType::Stdio, command: 'c'); |
52 | | - $server2 = new ServerConfig(name: 's2', transport: TransportType::Http, url: 'http://s'); |
| 51 | + $server = new ServerConfig(name: 's1', transport: TransportType::Stdio, command: 'c'); |
53 | 52 |
|
54 | 53 | // Act |
55 | 54 | $client = Client::make() |
|
61 | 60 | ->withEventDispatcher($dispatcher) |
62 | 61 | ->withLoop($loop) |
63 | 62 | ->withIdGenerator($idGen) |
64 | | - ->withServerConfig($server1) |
| 63 | + ->withServerConfig($server) |
65 | 64 | ->build(); |
66 | 65 |
|
67 | 66 | // Assert |
|
81 | 80 | expect($internalConfig->loop)->toBe($loop); |
82 | 81 | }); |
83 | 82 |
|
| 83 | +it('builds client with client info', function () { |
| 84 | + $server = new ServerConfig(name: 's1', transport: TransportType::Stdio, command: 'c'); |
| 85 | + |
| 86 | + // Arrange |
| 87 | + $client = Client::make() |
| 88 | + ->withClientInfo('TestClient', '1.0') |
| 89 | + ->withServerConfig($server) |
| 90 | + ->build(); |
| 91 | + |
| 92 | + // Assert |
| 93 | + expect($client)->toBeInstanceOf(Client::class); |
| 94 | + $reflector = new ReflectionClass($client); |
| 95 | + $configProp = $reflector->getProperty('clientConfig'); |
| 96 | + $configProp->setAccessible(true); |
| 97 | + $internalConfig = $configProp->getValue($client); |
| 98 | + |
| 99 | + expect($internalConfig->name)->toBe('TestClient'); |
| 100 | + expect($internalConfig->version)->toBe('1.0'); |
| 101 | +}); |
| 102 | + |
84 | 103 | it('throws exception if client name not provided', function () { |
85 | 104 | Client::make()->build(); |
86 | 105 | })->throws(ConfigurationException::class, 'Name must be provided using withName().'); |
|
0 commit comments