mockClient = $this->getMockBuilder(ClientInterface::class)->getMock(); } /** * @dataProvider responseProvider * @group disconnected * @param $readData * @param $expectedResponse * @return void */ public function testCurrentReturnsResponseFromServer($readData, $expectedResponse): void { $mockConnection = $this->getMockBuilder(NodeConnectionInterface::class)->getMock(); $mockConnection ->expects($this->once()) ->method('read') ->withAnyParameters() ->willReturn($readData); $this->mockClient ->expects($this->once()) ->method('getConnection') ->withAnyParameters() ->willReturn($mockConnection); $consumer = new Consumer($this->mockClient); $this->assertSame($expectedResponse, $consumer->current()); } /** * @group disconnected * @return void */ public function testConstructCallsGivenCallbackOnObjectInstantiation(): void { $this->mockClient ->expects($this->once()) ->method('disconnect') ->withAnyParameters(); $callback = static function (ClientInterface $client) { $client->disconnect(); }; new Consumer($this->mockClient, $callback); } public function responseProvider(): array { $pushResponse = new PushResponse(['messageType', 'payload']); return [ 'with push response' => [$pushResponse, $pushResponse], 'with another response' => ['string', null], ]; } }