public function testDisconnectWithNoConnection() { $fsockopen = $this->getFunctionMock('\\Phlib\\Beanstalk\\Connection', 'fsockopen'); $fsockopen->expects($this->any())->willReturn(true); $stream_set_timeout = $this->getFunctionMock('\\Phlib\\Beanstalk\\Connection', 'stream_set_timeout'); $stream_set_timeout->expects($this->any())->willReturn(true); $fsockopen = $this->getFunctionMock('\\Phlib\\Beanstalk\\Connection', 'fclose'); $fsockopen->expects($this->never()); // <- test here $socket = new Socket('host'); $socket->connect(); $socket->disconnect(); }
protected function execute($command, $response, $method, array $arguments = []) { $this->socket->expects($this->once())->method('write')->with($this->stringContains($command)); if (is_array($response)) { $thisReturn = call_user_func_array([$this, 'onConsecutiveCalls'], $response); $this->socket->expects($this->any())->method('read')->will($thisReturn); } else { $this->socket->expects($this->any())->method('read')->willReturn($response); } return call_user_func_array([$this->beanstalk, $method], $arguments); }