Permalink
Browse files

Adding failing test for zendframework/zendframework#3033

  • Loading branch information...
1 parent be56381 commit d60dae5c3a2f485e012548f3aee739f90256e48f @Ocramius Ocramius committed Nov 21, 2012
Showing with 34 additions and 0 deletions.
  1. +12 −0 tests/ZendTest/Http/Client/SocketTest.php
  2. +22 −0 tests/ZendTest/Http/Client/_files/fwrite.php
@@ -11,6 +11,7 @@
namespace ZendTest\Http\Client;
use Zend\Http\Client\Adapter;
+use Zend\Uri\Uri;
/**
* This Testsuite includes all Zend_Http_Client that require a working web
@@ -250,6 +251,17 @@ public function testMultibyteChunkedResponseZF6218()
}
/**
+ * Verifies that writing on a socket is considered valid even if 0 bytes
+ * were written.
+ */
+ public function testAllowsZeroWrittenBytes()
+ {
+ $this->_adapter->connect('localhost');
+ require_once __DIR__ . '/_files/fwrite.php';
+ $this->_adapter->write('GET', new Uri('tcp://localhost:80/'), '1.1', array(), 'test body');
+ }
+
+ /**
* Data Providers
*/
@@ -0,0 +1,22 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_Http
+ */
+
+namespace Zend\Http\Client\Adapter;
+
+/**
+ * This is a stub for PHP's `fwrite` function. It
+ * allows us to check that a write operation to a
+ * socket producing a returned "0 bytes" written
+ * is actually valid.
+ */
+function fwrite($socket, $request)
+{
+ return 0;
+}

0 comments on commit d60dae5

Please sign in to comment.