Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Various testsuite fixes #990

Closed
wants to merge 4 commits into from

3 participants

Dolf Schimmel Matthew Weier O'Phinney Marc Bennewitz
Dolf Schimmel
Collaborator

While fixing some functoinality I fixed these tests in the process.

Since I originally messed up some commits, this pull request is a follow up of pr-#989, so it's probably better to look at this after pr-#989 has been approved.

Benjamin Sch... and others added some commits
Matthew Weier O'Phinney

Unfortunately, tests still don't run for some of the classes referenced -- Wildfire, DbTable session save handler, and PHPUnit DBUnit support still fail. On the fence about merging this; while they're improvements, they don't fix anything tangible yet. :-(

Dolf Schimmel
Collaborator

@weierophinney While running the entire test suite I got some fatal errors which stopped execution of php. These tests resolve that (for the components covered). They do /not/ make every single test pass, but that never was the intention.

Matthew Weier O'Phinney

I was still getting fatal errors for the specific things covered by these changes.

Matthew Weier O'Phinney

These are still failing for me. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 24, 2012
  1. Dolf Schimmel

    Adding support for HTTP method PATCH. Functions the same as POST. Thi…

    Benjamin Scholler authored Freeaqingme committed
    …s is often used with RESTful APIs to modify batches of content.
  2. Dolf Schimmel

    Fixing typo.

    Benjamin Scholler authored Freeaqingme committed
Commits on Mar 30, 2012
  1. Dolf Schimmel
  2. Dolf Schimmel

    Various unittest fixes

    Freeaqingme authored
This page is out of date. Refresh to see the latest.
4 .gitignore
View
@@ -3,4 +3,6 @@ nbproject
.buildpath
.project
.settings/
-tmp/
+tmp/
+tests/TestConfiguration.php
+
5 library/Zend/Http/Client.php
View
@@ -356,7 +356,8 @@ public function setMethod($method)
$method = $this->getRequest()->setMethod($method)->getMethod();
if (($method == Request::METHOD_POST || $method == Request::METHOD_PUT ||
- $method == Request::METHOD_DELETE) && empty($this->encType)) {
+ $method == Request::METHOD_DELETE || $method == Request::METHOD_PATCH)
+ && empty($this->encType)) {
$this->setEncType(self::ENC_URLENCODED);
}
@@ -1083,7 +1084,7 @@ protected function prepareHeaders($body, $uri)
/**
- * Prepare the request body (for POST and PUT requests)
+ * Prepare the request body (for PATCH, POST and PUT requests)
*
* @return string
* @throws \Zend\Http\Client\Exception
15 library/Zend/Http/Request.php
View
@@ -22,6 +22,7 @@ class Request extends Message implements RequestDescription
const METHOD_DELETE = 'DELETE';
const METHOD_TRACE = 'TRACE';
const METHOD_CONNECT = 'CONNECT';
+ const METHOD_PATCH = 'PATCH';
/**#@-*/
/**#@+
@@ -92,7 +93,8 @@ public static function fromString($string)
$matches = null;
$methods = implode('|', array(
self::METHOD_OPTIONS, self::METHOD_GET, self::METHOD_HEAD, self::METHOD_POST,
- self::METHOD_PUT, self::METHOD_DELETE, self::METHOD_TRACE, self::METHOD_CONNECT
+ self::METHOD_PUT, self::METHOD_DELETE, self::METHOD_TRACE, self::METHOD_CONNECT,
+ self::METHOD_PATCH
));
$regex = '^(?P<method>' . $methods . ')\s(?<uri>[^ ]*)(?:\sHTTP\/(?<version>\d+\.\d+)){0,1}';
$firstLine = array_shift($lines);
@@ -513,6 +515,17 @@ public function isFlashRequest()
{
$header = $this->headers()->get('USER_AGENT');
return false !== $header && stristr($header->getFieldValue(), ' flash');
+
+ }
+
+ /*
+ * Is this a PATCH method request?
+ *
+ * @return bool
+ */
+ public function isPatch()
+ {
+ return ($this->method === self::METHOD_PATCH);
}
/**
4 library/Zend/Session/SaveHandler/DbTable.php
View
@@ -24,7 +24,7 @@
Zend\Session\SaveHandler as Savable,
Zend\Session\Container,
Zend\Session\Exception,
- Zend\Db\Table\AbstractTable,
+ Zend\Db\TableGateway\AbstractTableGateway,
Zend\Db\Table\AbstractRow;
/**
@@ -37,7 +37,7 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class DbTable
- extends AbstractTable
+ extends AbstractTableGateway
implements Savable
{
const NAME = 'name';
4 library/Zend/Wildfire/Channel/HttpHeaders.php
View
@@ -25,8 +25,8 @@
namespace Zend\Wildfire\Channel;
use Zend\Wildfire,
Zend\Wildfire\Protocol,
- Zend\Controller,
- Zend\Controller\Request\Http as HttpRequest;
+ Zend\Mvc\Controller,
+ Zend\Mvc\Controller\Request\Http as HttpRequest;
/**
* Implements communication via HTTP request and response headers for Wildfire Protocols.
2  tests/Zend/Date/DateTest.php
View
@@ -5234,7 +5234,7 @@ public function testSetOptions()
}
$cache = CacheFactory::adapterFactory('memory', array('memory_limit' => 0));
- Date\Date::setOptions(array('cache' => $cache));
+ Date::setOptions(array('cache' => $cache));
}
public function testIsDate()
78 tests/Zend/Di/DiTest.php
View
@@ -43,18 +43,18 @@ public function testDiConstructorCanTakeDependencies()
public function testPassingInvalidDefinitionRaisesException()
{
$di = new Di();
-
+
$this->setExpectedException('PHPUnit_Framework_Error');
$di->setDefinitionList(array('foo'));
}
-
+
public function testGetRetrievesObjectWithMatchingClassDefinition()
{
$di = new Di();
$obj = $di->get('ZendTest\Di\TestAsset\BasicClass');
$this->assertInstanceOf('ZendTest\Di\TestAsset\BasicClass', $obj);
}
-
+
public function testGetRetrievesSameInstanceOnSubsequentCalls()
{
$di = new Di();
@@ -64,23 +64,23 @@ public function testGetRetrievesSameInstanceOnSubsequentCalls()
$this->assertInstanceOf('ZendTest\Di\TestAsset\BasicClass', $obj2);
$this->assertSame($obj1, $obj2);
}
-
+
public function testGetThrowsExceptionWhenUnknownClassIsUsed()
{
$di = new Di();
-
+
$this->setExpectedException('Zend\Di\Exception\ClassNotFoundException', 'could not be located in');
$obj1 = $di->get('ZendTest\Di\TestAsset\NonExistentClass');
}
-
+
public function testGetThrowsExceptionWhenMissingParametersAreEncountered()
{
$di = new Di();
-
+
$this->setExpectedException('Zend\Di\Exception\MissingPropertyException', 'Missing instance/object for ');
$obj1 = $di->get('ZendTest\Di\TestAsset\BasicClassWithParam');
}
-
+
public function testNewInstanceReturnsDifferentInstances()
{
$di = new Di();
@@ -90,7 +90,7 @@ public function testNewInstanceReturnsDifferentInstances()
$this->assertInstanceOf('ZendTest\Di\TestAsset\BasicClass', $obj2);
$this->assertNotSame($obj1, $obj2);
}
-
+
public function testNewInstanceReturnsInstanceThatIsSharedWithGet()
{
$di = new Di();
@@ -100,7 +100,7 @@ public function testNewInstanceReturnsInstanceThatIsSharedWithGet()
$this->assertInstanceOf('ZendTest\Di\TestAsset\BasicClass', $obj2);
$this->assertSame($obj1, $obj2);
}
-
+
public function testNewInstanceReturnsInstanceThatIsNotSharedWithGet()
{
$di = new Di();
@@ -204,7 +204,7 @@ public function testGetWillResolveConstructorInjectionDependencies()
$this->assertInstanceOf('ZendTest\Di\TestAsset\ConstructorInjection\B', $b);
$this->assertInstanceOf('ZendTest\Di\TestAsset\ConstructorInjection\A', $b->a);
}
-
+
/**
* @group ConstructorInjection
*/
@@ -214,15 +214,15 @@ public function testGetWillResolveConstructorInjectionDependenciesAndInstanceAre
$b = $di->get('ZendTest\Di\TestAsset\ConstructorInjection\B');
$this->assertInstanceOf('ZendTest\Di\TestAsset\ConstructorInjection\B', $b);
$this->assertInstanceOf('ZendTest\Di\TestAsset\ConstructorInjection\A', $b->a);
-
+
$b2 = $di->get('ZendTest\Di\TestAsset\ConstructorInjection\B');
$this->assertInstanceOf('ZendTest\Di\TestAsset\ConstructorInjection\B', $b2);
$this->assertInstanceOf('ZendTest\Di\TestAsset\ConstructorInjection\A', $b2->a);
-
+
$this->assertSame($b, $b2);
$this->assertSame($b->a, $b2->a);
}
-
+
/**
* @group ConstructorInjection
*/
@@ -233,48 +233,48 @@ public function testNewInstanceWillResolveConstructorInjectionDependencies()
$this->assertInstanceOf('ZendTest\Di\TestAsset\ConstructorInjection\B', $b);
$this->assertInstanceOf('ZendTest\Di\TestAsset\ConstructorInjection\A', $b->a);
}
-
+
/**
* @group ConstructorInjection
*/
public function testNewInstanceWillResolveConstructorInjectionDependenciesWithProperties()
{
$di = new Di();
-
+
$im = $di->instanceManager();
$im->setParameters('ZendTest\Di\TestAsset\ConstructorInjection\X', array('one' => 1, 'two' => 2));
-
+
$y = $di->newInstance('ZendTest\Di\TestAsset\ConstructorInjection\Y');
$this->assertEquals(1, $y->x->one);
$this->assertEquals(2, $y->x->two);
}
-
+
/**
* @group ConstructorInjection
*/
public function testNewInstanceWillThrowExceptionOnConstructorInjectionDependencyWithMissingParameter()
{
$di = new Di();
-
+
$this->setExpectedException('Zend\Di\Exception\MissingPropertyException', 'Missing instance/object for parameter');
$b = $di->newInstance('ZendTest\Di\TestAsset\ConstructorInjection\X');
}
-
+
/**
* @group ConstructorInjection
*/
public function testNewInstanceWillResolveConstructorInjectionDependenciesWithMoreThan2Dependencies()
{
$di = new Di();
-
+
$im = $di->instanceManager();
$im->setParameters('ZendTest\Di\TestAsset\ConstructorInjection\X', array('one' => 1, 'two' => 2));
-
+
$z = $di->newInstance('ZendTest\Di\TestAsset\ConstructorInjection\Z');
$this->assertInstanceOf('ZendTest\Di\TestAsset\ConstructorInjection\Y', $z->y);
$this->assertInstanceOf('ZendTest\Di\TestAsset\ConstructorInjection\X', $z->y->x);
}
-
+
/**
* @group SetterInjection
*/
@@ -290,7 +290,7 @@ public function testGetWillResolveSetterInjectionDependencies()
$this->assertInstanceOf('ZendTest\Di\TestAsset\SetterInjection\B', $b);
$this->assertInstanceOf('ZendTest\Di\TestAsset\SetterInjection\A', $b->a);
}
-
+
/**
* @group SetterInjection
*/
@@ -306,16 +306,16 @@ public function testGetWillResolveSetterInjectionDependenciesAndInstanceAreTheSa
$b = $di->get('ZendTest\Di\TestAsset\SetterInjection\B');
$this->assertInstanceOf('ZendTest\Di\TestAsset\SetterInjection\B', $b);
$this->assertInstanceOf('ZendTest\Di\TestAsset\SetterInjection\A', $b->a);
-
+
$b2 = $di->get('ZendTest\Di\TestAsset\SetterInjection\B');
$this->assertInstanceOf('ZendTest\Di\TestAsset\SetterInjection\B', $b2);
$this->assertInstanceOf('ZendTest\Di\TestAsset\SetterInjection\A', $b2->a);
-
+
$this->assertSame($b, $b2);
$this->assertSame($b->a, $a);
$this->assertSame($b2->a, $a);
}
-
+
/**
* @group SetterInjection
*/
@@ -332,7 +332,7 @@ public function testNewInstanceWillResolveSetterInjectionDependencies()
$this->assertInstanceOf('ZendTest\Di\TestAsset\SetterInjection\B', $b);
$this->assertInstanceOf('ZendTest\Di\TestAsset\SetterInjection\A', $b->a);
}
-
+
/**
* @todo Setter Injections is not automatic, find a way to test this logically
*
@@ -341,7 +341,7 @@ public function testNewInstanceWillResolveSetterInjectionDependencies()
public function testNewInstanceWillResolveSetterInjectionDependenciesWithProperties()
{
$di = new Di();
-
+
$im = $di->instanceManager();
$im->setParameters('ZendTest\Di\TestAsset\SetterInjection\X', array('one' => 1, 'two' => 2));
@@ -351,10 +351,10 @@ public function testNewInstanceWillResolveSetterInjectionDependenciesWithPropert
$this->assertEquals(1, $y->x->one);
$this->assertEquals(2, $y->x->two);
}
-
+
/**
* Test for Circular Dependencies (case 1)
- *
+ *
* A->B, B->A
* @group CircularDependencyCheck
*/
@@ -365,10 +365,10 @@ public function testNewInstanceThrowsExceptionOnBasicCircularDependency()
$this->setExpectedException('Zend\Di\Exception\CircularDependencyException');
$di->newInstance('ZendTest\Di\TestAsset\CircularClasses\A');
}
-
+
/**
* Test for Circular Dependencies (case 2)
- *
+ *
* C->D, D->E, E->C
* @group CircularDependencyCheck
*/
@@ -382,10 +382,10 @@ public function testNewInstanceThrowsExceptionOnThreeLevelCircularDependency()
);
$di->newInstance('ZendTest\Di\TestAsset\CircularClasses\C');
}
-
+
/**
* Test for Circular Dependencies (case 2)
- *
+ *
* C->D, D->E, E->C
* @group CircularDependencyCheck
*/
@@ -399,10 +399,10 @@ public function testNewInstanceThrowsExceptionWhenEnteringInMiddleOfCircularDepe
);
$di->newInstance('ZendTest\Di\TestAsset\CircularClasses\D');
}
-
+
/**
* Fix for PHP bug in is_subclass_of
- *
+ *
* @see https://bugs.php.net/bug.php?id=53727
*/
public function testNewInstanceWillUsePreferredClassForInterfaceHints()
@@ -412,7 +412,7 @@ public function testNewInstanceWillUsePreferredClassForInterfaceHints()
'ZendTest\Di\TestAsset\PreferredImplClasses\A',
'ZendTest\Di\TestAsset\PreferredImplClasses\BofA'
);
-
+
$c = $di->get('ZendTest\Di\TestAsset\PreferredImplClasses\C');
$a = $c->a;
$this->assertInstanceOf('ZendTest\Di\TestAsset\PreferredImplClasses\BofA', $a);
@@ -590,7 +590,7 @@ public function testInjectionForSetterInjectionWillConsultSupertypeDefinitionInC
$this->assertInstanceOf('ZendTest\Di\TestAsset\SetterInjection\C', $c);
$this->assertInstanceOf('ZendTest\Di\TestAsset\SetterInjection\A', $c->a);
}
-
+
/**
* @group SharedInstance
*/
53 tests/Zend/Http/Client/CommonHttpTests.php
View
@@ -135,7 +135,7 @@ protected function tearDown()
public function testSimpleRequests()
{
$methods= array(Request::METHOD_GET, Request::METHOD_POST, Request::METHOD_OPTIONS,
- Request::METHOD_PUT, Request::METHOD_DELETE);
+ Request::METHOD_PUT, Request::METHOD_DELETE, Request::METHOD_PATCH);
foreach ($methods as $method) {
$this->client->setMethod($method);
@@ -194,13 +194,34 @@ public function testPostDataUrlEncoded($params)
$this->client->setEncType(HTTPClient::ENC_URLENCODED);
$this->client->setParameterPost($params);
-
+
$this->client->setMethod('POST');
+ $this->assertFalse($this->client->getRequest()->isPatch());
$res = $this->client->send();
$this->assertEquals(serialize($params), $res->getBody(), "POST data integrity test failed");
}
/**
+ * Test we can properly send PATCH parameters with
+ * application/x-www-form-urlencoded content type
+ *
+ * @dataProvider parameterArrayProvider
+ */
+ public function testPatchData($params)
+ {
+ $client = $this->client;
+ $client->setUri($this->baseuri . 'testPatchData.php');
+
+ $client->setRawBody(serialize($params));
+
+ $client->setMethod('PATCH');
+ $this->assertEquals($client::ENC_URLENCODED, $this->client->getEncType());
+ $this->assertTrue($client->getRequest()->isPatch());
+ $res = $this->client->send();
+ $this->assertEquals(serialize($params), $res->getBody(), "PATCH data integrity test failed");
+ }
+
+ /**
* Test we can properly send POST parameters with
* multipart/form-data content type
*
@@ -250,7 +271,7 @@ public function testResetParameters()
$this->client->setParameterGet($params);
$this->client->setHeaders($headers);
$this->client->setMethod('POST');
-
+
$res = $this->client->send();
$this->assertContains(serialize($params) . "\n" . serialize($params),
@@ -318,7 +339,7 @@ public function testHeadersSingle()
$this->client->setHeaders($headers);
$this->client->setMethod('TRACE');
-
+
$res = $this->client->send();
if ($res->getStatusCode() == 405 || $res->getStatusCode() == 501) {
$this->markTestSkipped("Server does not allow the TRACE method");
@@ -349,7 +370,7 @@ public function testHeadersArray()
$this->client->setHeaders($headers);
$this->client->setMethod('TRACE');
-
+
$res = $this->client->send();
if ($res->getStatusCode() == 405 || $res->getStatusCode() == 501) {
$this->markTestSkipped("Server does not allow the TRACE method");
@@ -389,7 +410,7 @@ public function testMultipleHeader()
$this->client->setHeaders($headers);
$this->client->setMethod('TRACE');
-
+
$res = $this->client->send();
if ($res->getStatusCode() == 405 || $res->getStatusCode() == 501) {
$this->markTestSkipped("Server does not allow the TRACE method");
@@ -485,7 +506,7 @@ public function testRedirectStrict()
$res = $this->client->send();
$this->assertEquals(3, $this->client->getRedirectionsCount(), 'Redirection counter is not as expected');
-
+
// Make sure the body *does* contain the set parameters
$this->assertContains('swallow', $res->getBody());
$this->assertContains('Camelot', $res->getBody());
@@ -532,11 +553,11 @@ public function testAbsolutePathRedirect()
$this->client->setConfig(array('maxredirects' => 1));
// Get the host and port part of our baseuri
- $port = ($this->client->getUri()->getPort() == 80) ? '' : ':' .$this->client->getUri()->getPort();
+ $port = ($this->client->getUri()->getPort() == 80) ? '' : ':' .$this->client->getUri()->getPort();
$uri = $this->client->getUri()->getScheme() . '://' . $this->client->getUri()->getHost() . $port;
-
+
$res = $this->client->send();
-
+
$this->assertEquals("{$uri}/path/to/fake/file.ext?redirect=abpath", $this->client->getUri()->toString(),
"The new location is not as expected: {$this->client->getUri()->toString()}");
}
@@ -640,7 +661,7 @@ public function testCookiesStringNoJar()
$this->client->setCookies($cookies);
$res = $this->client->send();
-
+
$this->assertEquals($res->getBody(), serialize($cookies), 'Response body does not contain the expected cookies');
}
@@ -817,7 +838,7 @@ public function testMutipleFilesWithSameFormNameZF5744()
$expectedBody .= "uploadfile $filename text/plain " . strlen($rawData) . "\n";
}
$this->client->setMethod('POST');
-
+
$res = $this->client->send();
$this->assertEquals($expectedBody, $res->getBody(), 'Response body does not include expected upload parameters');
@@ -866,7 +887,7 @@ public function testStreamResponse()
public function testStreamResponseBody()
{
$this->markTestSkipped('To check with the new ZF2 implementation');
-
+
if(!($this->client->getAdapter() instanceof Adapter\Stream)) {
$this->markTestSkipped('Current adapter does not support streaming');
return;
@@ -942,7 +963,7 @@ public function testZF9404DoubleContentLengthHeader()
}
$clen = $response->headers()->get('Content-Length');
-
+
if (! (is_array($clen))) {
$this->markTestSkipped("Didn't get multiple Content-length headers");
}
@@ -966,10 +987,10 @@ public function testContentTypeAdditionlInfo($params)
$this->client->setMethod(\Zend\Http\Request::METHOD_POST);
$this->client->setParameterPost($params);
-
+
$this->client->send();
$request = Request::fromString($this->client->getLastRawRequest());
- $this->assertEquals($content_type,
+ $this->assertEquals($content_type,
$request->headers()->get('Content-Type')->getFieldValue());
}
27 tests/Zend/Http/Client/_files/testPatchData.php
View
@@ -0,0 +1,27 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Http
+ * @subpackage UnitTests
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+$putdata = fopen("php://input", "r");
+while ($data = fread($putdata, 1024)) {
+ echo $data;
+}
+
+fclose($putdata);
6 tests/Zend/Test/PHPUnit/Db/Integration/AbstractTestCase.php
View
@@ -24,7 +24,7 @@
*/
namespace ZendTest\Test\PHPUnit\Db\Integration;
use Zend\Test\PHPUnit\Db\DataSet;
-use Zend\Db\Table;
+use Zend\Db\TableGateway;
/**
* @category Zend
@@ -119,14 +119,14 @@ public function createBarTable()
}
}
-class TableFoo extends Table\AbstractTable
+class TableFoo extends TableGateway\AbstractTableGateway
{
protected $_name = "foo";
protected $_primary = "id";
}
-class TableBar extends Table\AbstractTable
+class TableBar extends TableGateway\AbstractTableGateway
{
protected $_name = "bar";
4 tests/Zend/Wildfire/WildfireTest.php
View
@@ -1030,7 +1030,7 @@ class HttpHeadersChannel extends Channel\HttpHeaders
{
}
-class Request extends \Zend\Controller\Request\HttpTestCase
+class Request extends \Zend\Http\Request
{
protected $_enabled = false;
@@ -1060,7 +1060,7 @@ public function getHeader($header, $default = null)
}
-class Response extends \Zend\Controller\Response\HttpTestCase
+class Response extends \Zend\Http\Response
{
public function getHeadersForTesting()
Something went wrong with that request. Please try again.