Skip to content
This repository

Hotfix/issue #3033 #3049

Closed
wants to merge 2 commits into from

4 participants

Marco Pivetta Maks Matthew Weier O'Phinney Peter Hillerström
Marco Pivetta
Collaborator

Includes failing test (and the fix by @peterhil) for zendframework/zf2#3033

The test is a php internal function stub, so it may cause some troubles for further testing. Also, no assertions: not sure what to assert.

Maks
Collaborator

You could write a test returning false maybe tunning the return value with a var, constant.

I'm a little worried if PHPUnit forgets the file included after execute the test o if the return value is applied to the rest of the suite

Maks
Collaborator

Also you can add $this->assertTrue(true); // Exception is not raised at the end of the test

Maks
Collaborator

Finally I prefer not rewrite the commit of others (Git things) I understand that you rebased for verify the test before apply the fix but I think that is better save the original commit reference to avoid merge conflicts (with zf2 repository or other forks)

Maks Maks3w commented on the diff
tests/ZendTest/Http/Client/_files/fwrite.php
... ... @@ -0,0 +1,22 @@
  1 +<?php
3
Maks Collaborator
Maks3w added a note

This file should go Http/Client/Adapter/_files/

Marco Pivetta Collaborator

Ouch! Thank you for spotting it!

Marco Pivetta Collaborator

@Maks3w there's no such dir... wouldn't create it then...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Deleted user Unknown referenced this pull request from a commit
Matthew Weier O'Phinney weierophinney Merge branch 'hotfix/3049'
Fixes #3033
Close #3049
65cf549
Deleted user Unknown referenced this pull request from a commit
Matthew Weier O'Phinney weierophinney Merge branch 'hotfix/3049' into develop
Forward port #3049
91e7a8c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
2  library/Zend/Http/Client/Adapter/Socket.php
@@ -360,7 +360,7 @@ public function write($method, $uri, $http_ver = '1.1', $headers = array(), $bod
360 360 ErrorHandler::start();
361 361 $test = fwrite($this->socket, $request);
362 362 $error = ErrorHandler::stop();
363   - if (!$test) {
  363 + if (false === $test) {
364 364 throw new AdapterException\RuntimeException('Error writing request to server', 0, $error);
365 365 }
366 366
12 tests/ZendTest/Http/Client/SocketTest.php
@@ -11,6 +11,7 @@
11 11 namespace ZendTest\Http\Client;
12 12
13 13 use Zend\Http\Client\Adapter;
  14 +use Zend\Uri\Uri;
14 15
15 16 /**
16 17 * This Testsuite includes all Zend_Http_Client that require a working web
@@ -250,6 +251,17 @@ public function testMultibyteChunkedResponseZF6218()
250 251 }
251 252
252 253 /**
  254 + * Verifies that writing on a socket is considered valid even if 0 bytes
  255 + * were written.
  256 + */
  257 + public function testAllowsZeroWrittenBytes()
  258 + {
  259 + $this->_adapter->connect('localhost');
  260 + require_once __DIR__ . '/_files/fwrite.php';
  261 + $this->_adapter->write('GET', new Uri('tcp://localhost:80/'), '1.1', array(), 'test body');
  262 + }
  263 +
  264 + /**
253 265 * Data Providers
254 266 */
255 267
22 tests/ZendTest/Http/Client/_files/fwrite.php
... ... @@ -0,0 +1,22 @@
  1 +<?php
  2 +/**
  3 + * Zend Framework (http://framework.zend.com/)
  4 + *
  5 + * @link http://github.com/zendframework/zf2 for the canonical source repository
  6 + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  7 + * @license http://framework.zend.com/license/new-bsd New BSD License
  8 + * @package Zend_Http
  9 + */
  10 +
  11 +namespace Zend\Http\Client\Adapter;
  12 +
  13 +/**
  14 + * This is a stub for PHP's `fwrite` function. It
  15 + * allows us to check that a write operation to a
  16 + * socket producing a returned "0 bytes" written
  17 + * is actually valid.
  18 + */
  19 +function fwrite($socket, $request)
  20 +{
  21 + return 0;
  22 +}

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.