svn: /pecl/http/branches/DEV_2/ php_http_encoding.c php_http_message_body.c phpunit/MessageBodyTest.php

From: Date: Fri, 08 Nov 2013 12:58:59 +0000
Subject: svn: /pecl/http/branches/DEV_2/ php_http_encoding.c php_http_message_body.c phpunit/MessageBodyTest.php
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-19978@lists.php.net to get a copy of this message
mike Fri, 08 Nov 2013 12:58:59 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=332086 Log: standard return values; fix tests Changed paths: U pecl/http/branches/DEV_2/php_http_encoding.c U pecl/http/branches/DEV_2/php_http_message_body.c U pecl/http/branches/DEV_2/phpunit/MessageBodyTest.php Modified: pecl/http/branches/DEV_2/php_http_encoding.c =================================================================== --- pecl/http/branches/DEV_2/php_http_encoding.c 2013-11-08 08:15:20 UTC (rev 332085) +++ pecl/http/branches/DEV_2/php_http_encoding.c 2013-11-08 12:58:59 UTC (rev 332086) @@ -1021,7 +1021,6 @@ } } } - RETURN_FALSE; } ZEND_BEGIN_ARG_INFO_EX(ai_HttpEncodingStream_flush, 0, 0, 0) @@ -1044,10 +1043,9 @@ } } } - RETURN_FALSE; } -ZEND_BEGIN_ARG_INFO_EX(ai_HttpEncodingStream_done, 0, 0, 1) +ZEND_BEGIN_ARG_INFO_EX(ai_HttpEncodingStream_done, 0, 0, 0) ZEND_END_ARG_INFO(); static PHP_METHOD(HttpEncodingStream, done) { @@ -1058,7 +1056,6 @@ RETURN_BOOL(php_http_encoding_stream_done(obj->stream)); } } - RETURN_FALSE; } ZEND_BEGIN_ARG_INFO_EX(ai_HttpEncodingStream_finish, 0, 0, 0) @@ -1085,7 +1082,6 @@ } } } - RETURN_FALSE; } static zend_function_entry php_http_encoding_stream_methods[] = { Modified: pecl/http/branches/DEV_2/php_http_message_body.c =================================================================== --- pecl/http/branches/DEV_2/php_http_message_body.c 2013-11-08 08:15:20 UTC (rev 332085) +++ pecl/http/branches/DEV_2/php_http_message_body.c 2013-11-08 12:58:59 UTC (rev 332086) @@ -663,6 +663,8 @@ ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessageBody_toStream, 0, 0, 1) ZEND_ARG_INFO(0, stream) + ZEND_ARG_INFO(0, offset) + ZEND_ARG_INFO(0, maxlen) ZEND_END_ARG_INFO(); PHP_METHOD(HttpMessageBody, toStream) { @@ -677,13 +679,14 @@ php_stream_from_zval(stream, &zstream); php_http_message_body_to_stream(obj->body, stream, offset, forlen); - RETURN_TRUE; + RETURN_ZVAL(getThis(), 1, 0); } - RETURN_FALSE; } ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessageBody_toCallback, 0, 0, 1) ZEND_ARG_INFO(0, callback) + ZEND_ARG_INFO(0, offset) + ZEND_ARG_INFO(0, maxlen) ZEND_END_ARG_INFO(); PHP_METHOD(HttpMessageBody, toCallback) { @@ -703,9 +706,8 @@ zend_fcall_info_args_clear(&fcd.fci, 1); zval_ptr_dtor(&fcd.fcz); - RETURN_TRUE; + RETURN_ZVAL(getThis(), 1, 0); } - RETURN_FALSE; } ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessageBody_getResource, 0, 0, 0) @@ -735,9 +737,11 @@ PHP_HTTP_MESSAGE_BODY_OBJECT_INIT(obj); - RETURN_LONG(php_http_message_body_append(obj->body, str, len)); + if (len != php_http_message_body_append(obj->body, str, len)) { + php_http_error(HE_WARNING, PHP_HTTP_E_MESSAGE_BODY, "Could not append to body"); + } + RETURN_ZVAL(getThis(), 1, 0); } - RETURN_FALSE; } ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessageBody_addForm, 0, 0, 0) @@ -753,9 +757,9 @@ PHP_HTTP_MESSAGE_BODY_OBJECT_INIT(obj); - RETURN_BOOL(SUCCESS == php_http_message_body_add_form(obj->body, fields, files)); + php_http_message_body_add_form(obj->body, fields, files); + RETURN_ZVAL(getThis(), 1, 0); } - RETURN_FALSE; } ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessageBody_addPart, 0, 0, 1) @@ -772,9 +776,8 @@ PHP_HTTP_MESSAGE_BODY_OBJECT_INIT(obj); php_http_message_body_add_part(obj->body, mobj->message); - RETURN_TRUE; + RETURN_ZVAL(getThis(), 1, 0); } - RETURN_FALSE; } ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessageBody_etag, 0, 0, 0) @@ -789,13 +792,14 @@ if ((etag = php_http_message_body_etag(obj->body))) { RETURN_STRING(etag, 0); + } else { + RETURN_FALSE; } } - RETURN_FALSE; } ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessageBody_stat, 0, 0, 0) - ZEND_ARG_INFO(0, what) + ZEND_ARG_INFO(0, field) ZEND_END_ARG_INFO(); PHP_METHOD(HttpMessageBody, stat) { @@ -832,16 +836,14 @@ break; } } else { - array_init(return_value); - add_assoc_long_ex(return_value, ZEND_STRS("size"), sb->sb.st_size); - add_assoc_long_ex(return_value, ZEND_STRS("atime"), sb->sb.st_atime); - add_assoc_long_ex(return_value, ZEND_STRS("mtime"), sb->sb.st_mtime); - add_assoc_long_ex(return_value, ZEND_STRS("ctime"), sb->sb.st_ctime); - return; + object_init(return_value); + add_property_long_ex(return_value, ZEND_STRS("size"), sb->sb.st_size); + add_property_long_ex(return_value, ZEND_STRS("atime"), sb->sb.st_atime); + add_property_long_ex(return_value, ZEND_STRS("mtime"), sb->sb.st_mtime); + add_property_long_ex(return_value, ZEND_STRS("ctime"), sb->sb.st_ctime); } } } - RETURN_FALSE; } static zend_function_entry php_http_message_body_methods[] = { Modified: pecl/http/branches/DEV_2/phpunit/MessageBodyTest.php =================================================================== --- pecl/http/branches/DEV_2/phpunit/MessageBodyTest.php 2013-11-08 08:15:20 UTC (rev 332085) +++ pecl/http/branches/DEV_2/phpunit/MessageBodyTest.php 2013-11-08 12:58:59 UTC (rev 332086) @@ -14,7 +14,7 @@ $this->assertEquals(fileatime(__FILE__), $this->file->stat("atime")); $this->assertEquals(filectime(__FILE__), $this->file->stat("ctime")); $this->assertEquals( - array( + (object) array( "size" => 0, "mtime" => 0, "atime" => 0, @@ -24,26 +24,27 @@ ); } + function testAppendError() { + $this->setExpectedException("PHPUnit_Framework_Error"); + $this->file->append("nope"); + } function testAppend() { - $this->assertEquals(0, $this->file->append("nope")); - $this->assertEquals(3, $this->temp->append("yes")); + $this->temp->append("yes"); } function testAddForm() { - $this->assertTrue( - $this->temp->addForm( - array( - "foo" => "bar", - "more" => array( - "bah", "baz", "fuz" - ), + $this->temp->addForm( + array( + "foo" => "bar", + "more" => array( + "bah", "baz", "fuz" ), + ), + array( array( - array( - "file" => __FILE__, - "name" => "upload", - "type" => "text/plain", - ) + "file" => __FILE__, + "name" => "upload", + "type" => "text/plain", ) ) );

« previous php.pecl.cvs (#19978) next »