Skip to content

Loading…

[Tests] Enable more tests #1220

Merged
merged 6 commits into from

3 participants

@Maks3w
Zend Framework member

Another round for enable tests, this time some tests markedAsIncomplete has been reviewed.

Build Status

@akrabat akrabat commented on the diff
library/Zend/GData/App.php
@@ -628,10 +628,10 @@ public function performHttpRequest($method, $url, $headers = null,
// Set the params for the new request to be performed
$this->_httpClient->setHeaders($headers);
- $urlObj = Uri\UriFactory::factory($url);
@akrabat Zend Framework member
akrabat added a note

Why $url here when you renamed to $uri in prepareRequest() ?

@Maks3w Zend Framework member
Maks3w added a note

renamed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@akrabat
Zend Framework member

As a general rule, one PR per component for stuff like this would make it easier to review and merge.

@Maks3w Maks3w [Http] Enable Http tests & Fix PHP 5.4 issue
Headers with multiple values are now rendered splitting the values with commas ','
5212e48
@weierophinney weierophinney added a commit that referenced this pull request
@weierophinney weierophinney [#1220] Add curl opts to adapter
- Added CURLOPT_INFILESIZE to adapter config to fix error in tests
9be267b
@weierophinney weierophinney merged commit 5212e48 into zendframework:master
@ghost Unknown pushed a commit that referenced this pull request
@weierophinney weierophinney [#1220] Add curl opts to adapter
- Added CURLOPT_INFILESIZE to adapter config to fix error in tests
bea882a
@weierophinney weierophinney added a commit to zendframework/zend-http that referenced this pull request
@weierophinney weierophinney [zendframework/zf2#1220] Add curl opts to adapter
- Added CURLOPT_INFILESIZE to adapter config to fix error in tests
55a086d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 13, 2012
  1. @Maks3w

    [Feed] Remove duplicate test

    Maks3w committed
    This is duplicate with Reader/ReaderTest
  2. @Maks3w

    [Code] Some code fixes

    Maks3w committed
  3. @Maks3w

    [GData] Fix some tests

    Maks3w committed
Commits on May 15, 2012
  1. @Maks3w
  2. @Maks3w

    [GData] Test exceptions re-worked

    Maks3w committed
Commits on May 17, 2012
  1. @Maks3w

    [Http] Enable Http tests & Fix PHP 5.4 issue

    Maks3w committed
    Headers with multiple values are now rendered splitting the values with commas ','
View
2 library/Zend/Code/Generator/AbstractMemberGenerator.php
@@ -203,7 +203,7 @@ public function setStatic($isStatic)
*/
public function isStatic()
{
- return ($this->flags & self::FLAG_STATIC); // is FLAG_STATIC in flags
+ return (bool) ($this->flags & self::FLAG_STATIC); // is FLAG_STATIC in flags
}
/**
View
13 library/Zend/Code/Reflection/FileReflection.php
@@ -84,19 +84,18 @@ class FileReflection implements ReflectionInterface
/**
* Constructor
*
- * @param string $file
+ * @param string $filename
+ * @throws Exception\RuntimeException
* @return FileReflection
*/
- public function __construct($file)
+ public function __construct($filename)
{
- $fileName = $file;
-
- if (($fileRealPath = realpath($fileName)) === false) {
- $fileRealPath = stream_resolve_include_path($fileName);
+ if (($fileRealPath = realpath($filename)) === false) {
+ $fileRealPath = stream_resolve_include_path($filename);
}
if (!$fileRealPath || !in_array($fileRealPath, get_included_files())) {
- throw new Exception\RuntimeException('File ' . $file . ' must be required before it can be reflected');
+ throw new Exception\RuntimeException('File ' . $filename . ' must be required before it can be reflected');
}
$this->filePath = $fileRealPath;
View
28 library/Zend/GData/App.php
@@ -461,7 +461,7 @@ public function getMinorProtocolVersion()
*
* @param string $method The HTTP method for the request - 'GET', 'POST',
* 'PUT', 'DELETE'
- * @param string $url The URL to which this request is being performed,
+ * @param string $uri The URL to which this request is being performed,
* or null if found in $data
* @param array $headers An associative array of HTTP headers for this
* request
@@ -473,7 +473,7 @@ public function getMinorProtocolVersion()
* 'method', 'url', 'data', 'headers', 'contentType'
*/
public function prepareRequest($method,
- $url = null,
+ $uri = null,
$headers = array(),
$data = null,
$contentTypeOverride = null)
@@ -486,8 +486,8 @@ public function prepareRequest($method,
$rawData = null;
$finalContentType = null;
- if ($url == null) {
- $url = $this->_defaultPostUri;
+ if ($uri == null) {
+ $uri = $this->_defaultPostUri;
}
if (is_string($data)) {
@@ -506,8 +506,8 @@ public function prepareRequest($method,
}
if ($method == 'PUT' || $method == 'DELETE') {
$editLink = $data->getEditLink();
- if ($editLink != null && $url == null) {
- $url = $editLink->getHref();
+ if ($editLink != null && $uri == null) {
+ $uri = $editLink->getHref();
}
}
} elseif ($data instanceof App\Entry) {
@@ -516,7 +516,7 @@ public function prepareRequest($method,
if ($method == 'PUT' || $method == 'DELETE') {
$editLink = $data->getEditLink();
if ($editLink != null) {
- $url = $editLink->getHref();
+ $uri = $editLink->getHref();
}
}
} elseif ($data instanceof App\MediaSource) {
@@ -556,7 +556,7 @@ public function prepareRequest($method,
$finalContentType = $contentTypeOverride;
}
- return array('method' => $method, 'url' => $url,
+ return array('method' => $method, 'url' => $uri,
'data' => $rawData, 'headers' => $headers,
'contentType' => $finalContentType);
}
@@ -566,7 +566,7 @@ public function prepareRequest($method,
*
* @param string $method The HTTP method for the request - 'GET', 'POST',
* 'PUT', 'DELETE'
- * @param string $url The URL to which this request is being performed
+ * @param string $uri The URL to which this request is being performed
* @param array $headers An associative array of HTTP headers
* for this request
* @param string $body The body of the HTTP request
@@ -576,7 +576,7 @@ public function prepareRequest($method,
* s results in one
* @return \Zend\Http\Response The response object
*/
- public function performHttpRequest($method, $url, $headers = null,
+ public function performHttpRequest($method, $uri, $headers = null,
$body = null, $contentType = null, $remainingRedirects = null)
{
if ($remainingRedirects === null) {
@@ -602,7 +602,7 @@ public function performHttpRequest($method, $url, $headers = null,
'You must specify the data to post as either a ' .
'string or a child of Zend\GData\App\Entry');
}
- if ($url === null) {
+ if ($uri === null) {
throw new App\InvalidArgumentException(
'You must specify an URI to which to post.');
}
@@ -628,10 +628,10 @@ public function performHttpRequest($method, $url, $headers = null,
// Set the params for the new request to be performed
$this->_httpClient->setHeaders($headers);
- $urlObj = Uri\UriFactory::factory($url);
@akrabat Zend Framework member
akrabat added a note

Why $url here when you renamed to $uri in prepareRequest() ?

@Maks3w Zend Framework member
Maks3w added a note

renamed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
- preg_match("/^(.*?)(\?.*)?$/", $url, $matches);
+ $uriObj = Uri\UriFactory::factory($uri);
+ preg_match("/^(.*?)(\?.*)?$/", $uri, $matches);
$this->_httpClient->setUri($matches[1]);
- $queryArray = $urlObj->getQueryAsArray();
+ $queryArray = $uriObj->getQueryAsArray();
foreach ($queryArray as $name => $value) {
$this->_httpClient->setParameterGet($name, $value);
}
View
6 library/Zend/Http/Client/Adapter/Curl.php
@@ -336,7 +336,7 @@ public function write($method, $uri, $httpVersion = 1.1, $headers = array(), $bo
default:
// For now, through an exception for unsupported request methods
- throw new AdapterException\InvalidArgumentException("Method currently not supported");
+ throw new AdapterException\InvalidArgumentException("Method '$method' currently not supported");
}
if (is_resource($body) && $curlMethod != CURLOPT_UPLOAD) {
@@ -365,7 +365,9 @@ public function write($method, $uri, $httpVersion = 1.1, $headers = array(), $bo
}
// set additional headers
- $headers['Accept'] = '';
+ if (!isset($headers['Accept'])) {
+ $headers['Accept'] = '';
+ }
$curlHeaders = array();
foreach ($headers as $key => $value) {
$curlHeaders[] = $key . ': ' . $value;
View
12 library/Zend/Http/Client/Adapter/Test.php
@@ -23,8 +23,6 @@
use Traversable;
use Zend\Stdlib\ArrayUtils;
-use Zend\Http\Client\Adapter\AdapterInterface as HttpAdapter;
-use Zend\Http\Client\Adapter\Exception as AdapterException;
use Zend\Http\Response;
/**
@@ -41,7 +39,7 @@
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class Test implements HttpAdapter
+class Test implements AdapterInterface
{
/**
* Parameters array
@@ -103,7 +101,7 @@ public function setOptions($options = array())
}
if (! is_array($options)) {
- throw new AdapterException\InvalidArgumentException(
+ throw new Exception\InvalidArgumentException(
'Array or Traversable object expected, got ' . gettype($options)
);
}
@@ -121,13 +119,13 @@ public function setOptions($options = array())
* @param int $port
* @param boolean $secure
* @param int $timeout
- * @throws AdapterException\RuntimeException
+ * @throws Exception\RuntimeException
*/
public function connect($host, $port = 80, $secure = false)
{
if ($this->_nextRequestWillFail) {
$this->_nextRequestWillFail = false;
- throw new AdapterException\RuntimeException('Request failed');
+ throw new Exception\RuntimeException('Request failed');
}
}
@@ -224,7 +222,7 @@ public function addResponse($response)
public function setResponseIndex($index)
{
if ($index < 0 || $index >= count($this->responses)) {
- throw new AdapterException\OutOfRangeException(
+ throw new Exception\OutOfRangeException(
'Index out of range of response buffer size');
}
$this->responseIndex = $index;
View
3 library/Zend/Http/Headers.php
@@ -220,6 +220,9 @@ public function addHeaderLine($headerFieldNameOrLine, $fieldValue = null)
} else {
$headerName = $headerFieldNameOrLine;
$headerKey = str_replace(array('-', '_', ' ', '.'), '', strtolower($headerFieldNameOrLine));
+ if (is_array($fieldValue)) {
+ $fieldValue = implode(', ', $fieldValue);
+ }
$line = $headerFieldNameOrLine . ': ' . $fieldValue;
}
View
5 library/Zend/Uri/Http.php
@@ -23,7 +23,10 @@ class Http extends Uri
/**
* @see Uri::$validSchemes
*/
- protected static $validSchemes = array('http', 'https');
+ protected static $validSchemes = array(
+ 'http',
+ 'https'
+ );
/**
* @see Uri::$defaultPorts
View
2 library/Zend/Uri/Uri.php
@@ -123,7 +123,7 @@ class Uri
/**
* Create a new URI object
*
- * @param \Zend\Uri\Uri|string|null $uri
+ * @param Uri|string|null $uri
* @throws Exception\InvalidArgumentException
*/
public function __construct($uri = null)
View
4 tests/Zend/Code/Generator/PropertyGeneratorTest.php
@@ -160,9 +160,7 @@ public function testPropertyCanProduceStaticModifier()
*/
public function testPropertyWillLoadFromReflection()
{
- $this->markTestIncomplete('Skipped for now');
-
- $reflectionClass = new \Zend\Code\Reflection\ReflectionClass('\ZendTest\Code\Generator\TestAsset\TestClassWithManyProperties');
+ $reflectionClass = new \Zend\Code\Reflection\ClassReflection('\ZendTest\Code\Generator\TestAsset\TestClassWithManyProperties');
// test property 1
$reflProp = $reflectionClass->getProperty('_bazProperty');
View
2 tests/Zend/Code/Reflection/ClassReflectionTest.php
@@ -121,8 +121,6 @@ public function getIterator()
public function testStartLine()
{
- $this->markTestIncomplete('Line numbers not complete yet');
-
$reflectionClass = new ClassReflection('ZendTest\Code\Reflection\TestAsset\TestSampleClass5');
$this->assertEquals(16, $reflectionClass->getStartLine());
View
22 tests/Zend/Code/Reflection/ReflectionDocblockTagTest.php
@@ -42,7 +42,7 @@ public function setup()
public function testTagDescriptionIsReturned()
{
- $classReflection = new Reflection\ReflectionClass('ZendTest\Code\Reflection\TestAsset\TestSampleClass5');
+ $classReflection = new Reflection\ClassReflection('ZendTest\Code\Reflection\TestAsset\TestSampleClass5');
$authorTag = $classReflection->getDocblock()->getTag('author');
$this->assertEquals('Ralph Schindler <ralph.schindler@zend.com>', $authorTag->getDescription());
@@ -50,7 +50,7 @@ public function testTagDescriptionIsReturned()
public function testTagShouldAllowJustTagNameInDocblockTagLine()
{
- $classReflection = new Reflection\ReflectionClass('ZendTest\Code\Reflection\TestAsset\TestSampleClass6');
+ $classReflection = new Reflection\ClassReflection('ZendTest\Code\Reflection\TestAsset\TestSampleClass6');
$tag = $classReflection->getMethod('doSomething')->getDocblock()->getTag('emptyTag');
$this->assertEquals($tag->getName(), 'emptyTag', 'Factory First Match Failed');
@@ -58,7 +58,7 @@ public function testTagShouldAllowJustTagNameInDocblockTagLine()
public function testTagShouldAllowMultipleWhitespacesBeforeDescription()
{
- $classReflection = new Reflection\ReflectionClass('ZendTest\Code\Reflection\TestAsset\TestSampleClass6');
+ $classReflection = new Reflection\ClassReflection('ZendTest\Code\Reflection\TestAsset\TestSampleClass6');
$tag = $classReflection->getMethod('doSomething')->getDocblock()->getTag('descriptionTag');
$this->assertEquals(' A tag with just a description', $tag->getDescription(), 'Final Match Failed');
@@ -67,7 +67,7 @@ public function testTagShouldAllowMultipleWhitespacesBeforeDescription()
public function testToString()
{
- $classReflection = new Reflection\ReflectionClass('ZendTest\Code\Reflection\TestAsset\TestSampleClass6');
+ $classReflection = new Reflection\ClassReflection('ZendTest\Code\Reflection\TestAsset\TestSampleClass6');
$tag = $classReflection->getMethod('doSomething')->getDocblock()->getTag('descriptionTag');
@@ -79,7 +79,7 @@ public function testToString()
public function testTypeParam()
{
- $classReflection = new Reflection\ReflectionClass('ZendTest\Code\Reflection\TestAsset\TestSampleClass5');
+ $classReflection = new Reflection\ClassReflection('ZendTest\Code\Reflection\TestAsset\TestSampleClass5');
$paramTag = $classReflection->getMethod('doSomething')->getDocblock()->getTag('param');
@@ -88,7 +88,7 @@ public function testTypeParam()
public function testVariableName()
{
- $classReflection = new Reflection\ReflectionClass('ZendTest\Code\Reflection\TestAsset\TestSampleClass5');
+ $classReflection = new Reflection\ClassReflection('ZendTest\Code\Reflection\TestAsset\TestSampleClass5');
$paramTag = $classReflection->getMethod('doSomething')->getDocblock()->getTag('param');
$this->assertEquals($paramTag->getVariable(), '$one');
@@ -96,7 +96,7 @@ public function testVariableName()
public function testAllowsMultipleSpacesInDocblockTagLine()
{
- $classReflection = new Reflection\ReflectionClass('ZendTest\Code\Reflection\TestAsset\TestSampleClass6');
+ $classReflection = new Reflection\ClassReflection('ZendTest\Code\Reflection\TestAsset\TestSampleClass6');
$paramTag = $classReflection->getMethod('doSomething')->getDocblock()->getTag('param');
@@ -113,7 +113,7 @@ public function testAllowsMultipleSpacesInDocblockTagLine()
*/
public function testNamespaceInParam()
{
- $classReflection = new Reflection\ReflectionClass('ZendTest\Code\Reflection\TestAsset\TestSampleClass7');
+ $classReflection = new Reflection\ClassReflection('ZendTest\Code\Reflection\TestAsset\TestSampleClass7');
$paramTag = $classReflection->getMethod('doSomething')->getDocblock()->getTag('param');
$trimOpt = Reflection\ReflectionDocblockTag::TRIM_WHITESPACE;
@@ -125,7 +125,7 @@ public function testNamespaceInParam()
public function testType()
{
- $classReflection = new Reflection\ReflectionClass('ZendTest\Code\Reflection\TestAsset\TestSampleClass5');
+ $classReflection = new Reflection\ClassReflection('ZendTest\Code\Reflection\TestAsset\TestSampleClass5');
$paramTag = $classReflection->getMethod('doSomething')->getDocblock()->getTag('return');
$this->assertEquals($paramTag->getType(), 'mixed');
@@ -133,7 +133,7 @@ public function testType()
public function testAllowsMultipleSpacesInDocblockTagLine2()
{
- $classReflection = new Reflection\ReflectionClass('ZendTest\Code\Reflection\TestAsset\TestSampleClass6');
+ $classReflection = new Reflection\ClassReflection('ZendTest\Code\Reflection\TestAsset\TestSampleClass6');
$trimOpt = Reflection\ReflectionDocblockTag::TRIM_WHITESPACE;
@@ -150,7 +150,7 @@ public function testAllowsMultipleSpacesInDocblockTagLine2()
*/
public function testReturnClassWithNamespace()
{
- $classReflection = new Reflection\ReflectionClass('ZendTest\Code\Reflection\TestAsset\TestSampleClass7');
+ $classReflection = new Reflection\ClassReflection('ZendTest\Code\Reflection\TestAsset\TestSampleClass7');
$paramTag = $classReflection->getMethod('doSomething')->getDocblock()->getTag('return');
View
373 tests/Zend/Feed/ReaderTest.php
@@ -1,373 +0,0 @@
-<?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_Feed
- * @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
- */
-
-namespace ZendTest\Feed;
-use Zend\Feed\Reader;
-
-/**
- * @category Zend
- * @package Zend_Feed
- * @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
- * @group Zend_Feed
- * @group Zend_Feed_Reader
- */
-class ReaderTest extends \PHPUnit_Framework_TestCase
-{
-
- protected $_feedSamplePath = null;
-
- public function setup()
- {
- $this->_feedSamplePath = __DIR__ . '/Reader/_files';
- }
-
- public function tearDown()
- {
- Reader\Reader::reset();
- }
-
- public function testDetectsFeedIsRss20()
- {
- $feed = Reader\Reader::importString(
- file_get_contents($this->_feedSamplePath.'/Reader/rss20.xml'));
- $type = Reader\Reader::detectType($feed);
- $this->assertEquals(Reader\Reader::TYPE_RSS_20, $type);
- }
-
- public function testDetectsFeedIsRss094()
- {
- $feed = Reader\Reader::importString(
- file_get_contents($this->_feedSamplePath.'/Reader/rss094.xml'));
- $type = Reader\Reader::detectType($feed);
- $this->assertEquals(Reader\Reader::TYPE_RSS_094, $type);
- }
-
- public function testDetectsFeedIsRss093()
- {
- $feed = Reader\Reader::importString(
- file_get_contents($this->_feedSamplePath.'/Reader/rss093.xml'));
- $type = Reader\Reader::detectType($feed);
- $this->assertEquals(Reader\Reader::TYPE_RSS_093, $type);
- }
-
- public function testDetectsFeedIsRss092()
- {
- $feed = Reader\Reader::importString(
- file_get_contents($this->_feedSamplePath.'/Reader/rss092.xml'));
- $type = Reader\Reader::detectType($feed);
- $this->assertEquals(Reader\Reader::TYPE_RSS_092, $type);
- }
-
- public function testDetectsFeedIsRss091()
- {
- $feed = Reader\Reader::importString(
- file_get_contents($this->_feedSamplePath.'/Reader/rss091.xml'));
- $type = Reader\Reader::detectType($feed);
- $this->assertEquals(Reader\Reader::TYPE_RSS_091, $type);
- }
-
- public function testDetectsFeedIsRss10()
- {
- $feed = Reader\Reader::importString(
- file_get_contents($this->_feedSamplePath.'/Reader/rss10.xml'));
- $type = Reader\Reader::detectType($feed);
- $this->assertEquals(Reader\Reader::TYPE_RSS_10, $type);
- }
-
- public function testDetectsFeedIsRss090()
- {
- $feed = Reader\Reader::importString(
- file_get_contents($this->_feedSamplePath.'/Reader/rss090.xml'));
- $type = Reader\Reader::detectType($feed);
- $this->assertEquals(Reader\Reader::TYPE_RSS_090, $type);
- }
-
- public function testDetectsFeedIsAtom10()
- {
- $feed = Reader\Reader::importString(
- file_get_contents($this->_feedSamplePath.'/Reader/atom10.xml'));
- $type = Reader\Reader::detectType($feed);
- $this->assertEquals(Reader\Reader::TYPE_ATOM_10, $type);
- }
-
- public function testDetectsFeedIsAtom03()
- {
- $feed = Reader\Reader::importString(
- file_get_contents($this->_feedSamplePath.'/Reader/atom03.xml'));
- $type = Reader\Reader::detectType($feed);
- $this->assertEquals(Reader\Reader::TYPE_ATOM_03, $type);
- }
-
- /**
- * @group ZF-9723
- */
- public function testDetectsTypeFromStringOrToRemindPaddyAboutForgettingATestWhichLetsAStupidTypoSurviveUnnoticedForMonths()
- {
- $feed = '<?xml version="1.0" encoding="utf-8" ?><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/"><channel></channel></rdf:RDF>';
- $type = Reader\Reader::detectType($feed);
- $this->assertEquals(Reader\Reader::TYPE_RSS_10, $type);
- }
-
- public function testGetEncoding()
- {
- $feed = Reader\Reader::importString(
- file_get_contents(__DIR__ . '/Reader/Entry/_files/Atom/title/plain/atom10.xml')
- );
-
- $this->assertEquals('utf-8', $feed->getEncoding());
- $this->assertEquals('utf-8', $feed->current()->getEncoding());
- }
-
- public function testImportsFile()
- {
- try {
- $feed = Reader\Reader::importFile(
- __DIR__ . '/Reader/Entry/_files/Atom/title/plain/atom10.xml'
- );
- } catch(\Exception $e) {
- $this->fail($e->getMessage());
- }
- }
-
- public function testImportsUri()
- {
- if (!defined('TESTS_ZEND_FEED_READER_ONLINE_ENABLED')
- || !constant('TESTS_ZEND_FEED_READER_ONLINE_ENABLED')
- ) {
- $this->markTestSkipped('testImportsUri() requires a network connection');
- return;
- }
-
- try {
- $feed = Reader\Reader::import('http://www.planet-php.net/rdf/');
- } catch(\Exception $e) {
- $this->fail($e->getMessage());
- }
- }
-
- /**
- * @group ZF-8328
- */
- public function testImportsUriAndThrowsExceptionIfNotAFeed()
- {
- $this->setExpectedException('Zend\Feed\Exception\ExceptionInterface');
- if (!defined('TESTS_ZEND_FEED_READER_ONLINE_ENABLED')
- || !constant('TESTS_ZEND_FEED_READER_ONLINE_ENABLED')
- ) {
- $this->markTestSkipped('testImportsUri() requires a network connection');
- return;
- }
-
- $feed = Reader\Reader::import('http://twitter.com/alganet');
- }
-
- public function testGetsFeedLinksAsValueObject()
- {
- if (!defined('TESTS_ZEND_FEED_READER_ONLINE_ENABLED')
- || !constant('TESTS_ZEND_FEED_READER_ONLINE_ENABLED')
- ) {
- $this->markTestSkipped('testGetsFeedLinksAsValueObject() requires a network connection');
- return;
- }
-
- try {
- $links = Reader\Reader::findFeedLinks('http://www.planet-php.net');
- } catch(\Exception $e) {
- $this->fail($e->getMessage());
- }
- $this->assertEquals('http://www.planet-php.org/rss/', $links->rss);
- }
-
- public function testCompilesLinksAsArrayObject()
- {
- if (!defined('TESTS_ZEND_FEED_READER_ONLINE_ENABLED')
- || !constant('TESTS_ZEND_FEED_READER_ONLINE_ENABLED')
- ) {
- $this->markTestSkipped('testGetsFeedLinksAsValueObject() requires a network connection');
- return;
- }
- $links = Reader\Reader::findFeedLinks('http://www.planet-php.net');
- $this->assertTrue($links instanceof Reader\FeedSet);
- $this->assertEquals(array(
- 'rel' => 'alternate', 'type' => 'application/rss+xml', 'href' => 'http://www.planet-php.org/rss/'
- ), (array) $links->getIterator()->current());
- }
-
- public function testFeedSetLoadsFeedObjectWhenFeedArrayKeyAccessed()
- {
- if (!defined('TESTS_ZEND_FEED_READER_ONLINE_ENABLED')
- || !constant('TESTS_ZEND_FEED_READER_ONLINE_ENABLED')
- ) {
- $this->markTestSkipped('testGetsFeedLinksAsValueObject() requires a network connection');
- return;
- }
- $links = Reader\Reader::findFeedLinks('http://www.planet-php.net');
- $link = $links->getIterator()->current();
- $this->assertTrue($link['feed'] instanceof \Zend\Feed\Reader\Feed\RSS);
- }
-
- public function testZeroCountFeedSetReturnedFromEmptyList()
- {
- if (!defined('TESTS_ZEND_FEED_READER_ONLINE_ENABLED')
- || !constant('TESTS_ZEND_FEED_READER_ONLINE_ENABLED')
- ) {
- $this->markTestSkipped('testGetsFeedLinksAsValueObject() requires a network connection');
- return;
- }
- $links = Reader\Reader::findFeedLinks('http://www.example.com');
- $this->assertEquals(0, count($links));
- }
-
- /**
- * @group ZF-8327
- */
- public function testGetsFeedLinksAndTrimsNewlines()
- {
- if (!defined('TESTS_ZEND_FEED_READER_ONLINE_ENABLED')
- || !constant('TESTS_ZEND_FEED_READER_ONLINE_ENABLED')
- ) {
- $this->markTestSkipped('testGetsFeedLinksAsValueObject() requires a network connection');
- return;
- }
-
- try {
- $links = Reader\Reader::findFeedLinks('http://www.infopod.com.br');
- } catch(\Exception $e) {
- $this->fail($e->getMessage());
- }
- $this->assertEquals('http://feeds.feedburner.com/jonnyken/infoblog', $links->rss);
- }
-
- /**
- * @group ZF-8330
- */
- public function testGetsFeedLinksAndNormalisesRelativeUrls()
- {
- if (!defined('TESTS_ZEND_FEED_READER_ONLINE_ENABLED')
- || !constant('TESTS_ZEND_FEED_READER_ONLINE_ENABLED')
- ) {
- $this->markTestSkipped('testGetsFeedLinksAsValueObject() requires a network connection');
- return;
- }
-
- try {
- $links = Reader\Reader::findFeedLinks('http://meiobit.com');
- } catch(\Exception $e) {
- $this->fail($e->getMessage());
- }
- $this->assertEquals('http://meiobit.com/rss.xml', $links->rss);
- }
-
- /**
- * @group ZF-8330
- */
- public function testGetsFeedLinksAndNormalisesRelativeUrlsOnUriWithPath()
- {
- try {
- $currClient = Reader\Reader::getHttpClient();
-
- $response = new \Zend\Http\Response;
- $response->setContent('<!DOCTYPE html><html><head><link rel="alternate" type="application/rss+xml" href="../test.rss"><link rel="alternate" type="application/atom+xml" href="/test.atom"></head><body></body></html>');
- $response->setStatusCode(200);
-
- $testAdapter = new \Zend\Http\Client\Adapter\Test();
- $testAdapter->setResponse($response);
- Reader\Reader::setHttpClient(new \Zend\Http\Client(null, array('adapter' => $testAdapter)));
-
- $links = Reader\Reader::findFeedLinks('http://foo/bar');
-
- Reader\Reader::setHttpClient($currClient);
- } catch(\Exception $e) {
- $this->fail($e->getMessage());
- }
-
- $this->assertEquals('http://foo/test.rss', $links->rss);
- $this->assertEquals('http://foo/test.atom', $links->atom);
- }
-
- public function testAddsPrefixPath()
- {
- Reader\Reader::addPrefixPath('A\B\C', '/A/B/C');
- $prefixPaths = Reader\Reader::getPluginLoader()->getPaths();
- $this->assertEquals('/A/B/C/', $prefixPaths['A\B\C\\'][0]);
- }
-
- public function testRegistersUserExtension()
- {
- try {
- Reader\Reader::addPrefixPath('My\Extension', __DIR__ . '/Reader/_files/My/Extension');
- Reader\Reader::registerExtension('JungleBooks');
- } catch(\Exception $e) {
- $this->fail($e->getMessage());
- }
- $this->assertTrue(Reader\Reader::isRegistered('JungleBooks'));
- }
-
- protected function _getTempDirectory()
- {
- $tmpdir = array();
- foreach (array($_ENV, $_SERVER) as $tab) {
- foreach (array('TMPDIR', 'TEMP', 'TMP', 'windir', 'SystemRoot') as $key) {
- if (isset($tab[$key])) {
- if (($key == 'windir') or ($key == 'SystemRoot')) {
- $dir = realpath($tab[$key] . '\\temp');
- } else {
- $dir = realpath($tab[$key]);
- }
- if ($this->_isGoodTmpDir($dir)) {
- return $dir;
- }
- }
- }
- }
- if (function_exists('sys_get_temp_dir')) {
- $dir = sys_get_temp_dir();
- if ($this->_isGoodTmpDir($dir)) {
- return $dir;
- }
- }
- $tempFile = tempnam(md5(uniqid(rand(), TRUE)), '');
- if ($tempFile) {
- $dir = realpath(dirname($tempFile));
- unlink($tempFile);
- if ($this->_isGoodTmpDir($dir)) {
- return $dir;
- }
- }
- if ($this->_isGoodTmpDir('/tmp')) {
- return '/tmp';
- }
- if ($this->_isGoodTmpDir('\\temp')) {
- return '\\temp';
- }
- }
-
- protected function _isGoodTmpDir($dir)
- {
- if (is_readable($dir) && is_writable($dir)) {
- return true;
- }
- return false;
- }
-
-}
View
44 tests/Zend/GData/App/EntryTest.php
@@ -26,7 +26,7 @@
Zend\GData\App\Extension,
Zend\Http,
Zend\Http\Header\Etag,
- Zend\URI,
+ Zend\Uri,
ZendTest\GData\TestAsset;
/**
@@ -40,11 +40,16 @@
*/
class EntryTest extends \PHPUnit_Framework_TestCase
{
-
- /**
- * @var \Zend\GData\App
- */
- protected $service = null;
+ public $entryText;
+ public $httpEntrySample;
+ /** @var \Zend\GData\App */
+ public $entry;
+ /** @var \Zend\Http\Client\Adapter\AdapterInterface */
+ public $adapter;
+ /** @var \Zend\GData\HttpClient */
+ public $client;
+ /** @var App */
+ public $service;
public function setUp()
{
@@ -236,7 +241,6 @@ public function testDeleteSupportsGDataV2()
public function testIfMatchHeaderCanBeSetOnSave()
{
- $this->markTestIncomplete('Problem with Etag and If-Match');
$etagOverride = 'foo';
$etag = Etag::fromString('Etag: ABCD1234');
$this->service->setMajorProtocolVersion(2);
@@ -252,7 +256,7 @@ public function testIfMatchHeaderCanBeSetOnSave()
$headers = $this->adapter->popRequest()->headers;
$found = false;
foreach ($headers as $header => $value) {
- if ($header == 'If-Match: ' && $value == $etagOverride)
+ if ($header == 'If-Match' && $value == $etagOverride)
$found = true;
}
$this->assertTrue($found,
@@ -285,10 +289,9 @@ public function testIfNoneMatchHeaderCanBeSetOnSave()
public function testCanSetUriOnSave()
{
- $this->markTestIncomplete('Problem with default port');
- $uri = 'http://example.net/foo/bar';
+ $uri = 'http://example.net:8080/foo/bar';
$uriObject = new Uri\Http($uri);
- $uriObject->setPort('80');
+ $uriObject->setPort('8080');
$this->adapter->setResponse($this->httpEntrySample);
$entry = $this->service->newEntry();
$newEntry = $entry->save($uri);
@@ -312,7 +315,6 @@ public function testCanSetClassnameOnSave()
public function testIfNoneMatchSetOnReload()
{
- $this->markTestIncomplete('Problem with Etag and If-Match');
$etag = Etag::fromString('Etag: ABCD1234');
$this->adapter->setResponse($this->httpEntrySample);
$entry = $this->service->newEntry();
@@ -325,16 +327,14 @@ public function testIfNoneMatchSetOnReload()
$headers = $this->adapter->popRequest()->headers;
$found = false;
foreach ($headers as $header => $value) {
- if ($header == 'If-None-Match: ' && $value == $etag)
+ if ($header == 'If-None-Match' && $value == $etag->getFieldValue())
$found = true;
}
- $this->assertTrue($found,
- 'If-None-Match header not found or incorrect');
+ $this->assertTrue($found, 'If-None-Match header not found or incorrect');
}
public function testIfNoneMatchCanBeSetOnReload()
{
- $this->markTestIncomplete('Problem with Etag and If-Match');
$etagOverride = 'foo';
$etag = Etag::fromString('Etag: ABCD1234');
$this->adapter->setResponse($this->httpEntrySample);
@@ -349,11 +349,10 @@ public function testIfNoneMatchCanBeSetOnReload()
$headers = $this->adapter->popRequest()->headers;
$found = false;
foreach ($headers as $header => $value) {
- if ($header == 'If-None-Match: ' && $value == $etagOverride)
+ if ($header == 'If-None-Match' && $value == $etagOverride)
$found = true;
}
- $this->assertTrue($found,
- 'If-None-Match header not found or incorrect');
+ $this->assertTrue($found,'If-None-Match header not found or incorrect');
}
public function testReloadReturnsEntryObject()
@@ -398,8 +397,7 @@ public function testReloadDoesntThrowExceptionIfNoEtag()
public function testReloadExtractsURIFromEditLink()
{
- $this->markTestIncomplete('Problem with default port');
- $expectedUri = 'http://www.example.com';
+ $expectedUri = 'http://www.example.com:81';
$etag = Etag::fromString('Etag: ABCD1234');
$this->service->setMajorProtocolVersion(2);
$this->adapter->setResponse($this->httpEntrySample);
@@ -412,13 +410,12 @@ public function testReloadExtractsURIFromEditLink()
$newEntry = $entry->reload();
$requestUri = $this->adapter->popRequest()->uri;
$expectedUriObject = new Uri\Http($expectedUri);
- $expectedUriObject->setPort('80');
+ $expectedUriObject->setPort('81');
$this->assertEquals($expectedUriObject, $requestUri);
}
public function testReloadAllowsCustomURI()
{
- $this->markTestIncomplete('Problem with default port');
$uriOverride = 'http://www.example.org';
$etag = Etag::fromString('Etag: ABCD1234');
$this->service->setMajorProtocolVersion(2);
@@ -432,7 +429,6 @@ public function testReloadAllowsCustomURI()
$newEntry = $entry->reload($uriOverride);
$requestUri = $this->adapter->popRequest()->uri;
$uriOverrideObject = new Uri\Http($uriOverride);
- $uriOverrideObject->setPort('80');
$this->assertEquals($uriOverrideObject, $requestUri);
}
View
62 tests/Zend/GData/AppTest.php
@@ -21,7 +21,8 @@
namespace ZendTest\GData;
-use Zend\GData\App,
+use Zend\GData,
+ Zend\GData\App,
Zend\GData\App\Extension,
Zend\Http\Header\Etag,
ZendTest\GData\TestAsset;
@@ -37,6 +38,21 @@
*/
class AppTest extends \PHPUnit_Framework_TestCase
{
+ public $fileName;
+ public $expectedEtagValue;
+ public $expectedMajorProtocolVersion;
+ public $expectedMinorProtocolVersion;
+ public $httpEntrySample;
+ public $httpEntrySampleWithoutVersion;
+ public $httpFeedSample;
+ public $httpFeedSampleWithoutVersion;
+ /** @var \Zend\Http\Client\Adapter\AdapterInterface */
+ public $adapter;
+ /** @var \Zend\GData\HttpClient */
+ public $client;
+ /** @var App */
+ public $service;
+
public function setUp()
{
$this->fileName = 'Zend/GData/App/_files/FeedSample1.xml';
@@ -57,7 +73,7 @@ public function setUp()
true);
$this->adapter = new TestAsset\MockHttpClient();
- $this->client = new \Zend\GData\HttpClient();
+ $this->client = new GData\HttpClient();
$this->client->setAdapter($this->adapter);
$this->service = new App($this->client);
}
@@ -91,38 +107,20 @@ public function testDefaultProtocolVersionIs1X()
public function testMajorProtocolVersionCannotBeLessThanOne()
{
- $exceptionCaught = false;
- try {
- $this->service->setMajorProtocolVersion(0);
- } catch (App\InvalidArgumentException $e) {
- $exceptionCaught = true;
- }
- $this->assertTrue($exceptionCaught, 'Expected exception not caught: '
- + 'Zend_GData_App_InvalidArgumentException');
+ $this->setExpectedException('\Zend\GData\App\InvalidArgumentException');
+ $this->service->setMajorProtocolVersion(0);
}
public function testMajorProtocolVersionCannotBeNull()
{
- $exceptionCaught = false;
- try {
- $this->service->setMajorProtocolVersion(null);
- } catch (App\InvalidArgumentException $e) {
- $exceptionCaught = true;
- }
- $this->assertTrue($exceptionCaught, 'Expected exception not caught: '
- + 'Zend_GData_App_InvalidArgumentException');
+ $this->setExpectedException('\Zend\GData\App\InvalidArgumentException');
+ $this->service->setMajorProtocolVersion(null);
}
public function testMinorProtocolVersionCannotBeLessThanZero()
{
- $exceptionCaught = false;
- try {
- $this->service->setMinorProtocolVersion(-1);
- } catch (App\InvalidArgumentException $e) {
- $exceptionCaught = true;
- }
- $this->assertTrue($exceptionCaught, 'Expected exception not caught: '
- + 'Zend_GData_App_InvalidArgumentException');
+ $this->setExpectedException('\Zend\GData\App\InvalidArgumentException');
+ $this->service->setMinorProtocolVersion(-1);
}
public function testNoGDataVersionHeaderSentWhenUsingV1()
@@ -218,7 +216,6 @@ public function testHttpEtagsPropagateToEntriesOnInsert()
public function testIfMatchHttpHeaderSetOnUpdate()
{
- $this->markTestIncomplete('Problem with Etag and If-Match');
$etag = Etag::fromString('Etag: ABCD1234');
$this->adapter->setResponse("HTTP/1.1 201 Created");
$this->service->setMajorProtocolVersion(2);
@@ -261,7 +258,6 @@ public function testIfMatchHttpHeaderSetOnUpdateIfWeak()
public function testIfMatchHttpHeaderSetOnSave()
{
- $this->markTestIncomplete('Problem with Etag and If-Match');
$etag = Etag::fromString('Etag: ABCD1234');
$this->adapter->setResponse("HTTP/1.1 201 Created");
$this->service->setMajorProtocolVersion(2);
@@ -306,7 +302,6 @@ public function testIfMatchHttpHeaderNotSetOnDelete()
public function testIfMatchHttpHeaderSetOnManualPost()
{
- $this->markTestIncomplete('Problem with Etag and If-Match');
$etag = Etag::fromString('Etag: ABCD1234');
$this->adapter->setResponse("HTTP/1.1 201 Created");
$this->service->setMajorProtocolVersion(2);
@@ -325,7 +320,6 @@ public function testIfMatchHttpHeaderSetOnManualPost()
public function testIfMatchHttpHeaderSetOnManualPut()
{
- $this->markTestIncomplete('Problem with Etag and If-Match');
$etag = Etag::fromString('Etag: ABCD1234');
$this->adapter->setResponse("HTTP/1.1 201 Created");
$this->service->setMajorProtocolVersion(2);
@@ -370,7 +364,6 @@ public function testIfMatchHttpHeaderSetOnManualDelete()
public function testIfMatchHeaderCanBeSetOnInsert()
{
- $this->markTestIncomplete('Problem with Etag and If-Match');
$etagOverride = 'foo';
$etag = Etag::fromString('Etag: ABCD1234');
$this->service->setMajorProtocolVersion(2);
@@ -384,7 +377,7 @@ public function testIfMatchHeaderCanBeSetOnInsert()
$headers = $this->adapter->popRequest()->headers;
$found = false;
foreach ($headers as $header => $value) {
- if ($header == 'If-Match' && $value == $etag->getFieldValue())
+ if ($header == 'If-Match' && $value == $etagOverride)
$found = true;
}
$this->assertTrue($found, 'If-Match header not found or incorrect');
@@ -392,7 +385,6 @@ public function testIfMatchHeaderCanBeSetOnInsert()
public function testIfNoneMatchHeaderCanBeSetOnInsert()
{
- $this->markTestIncomplete('Problem with Etag and If-Match');
$etagOverride = 'foo';
$etag = Etag::fromString('Etag: ABCD1234');
$this->service->setMajorProtocolVersion(2);
@@ -406,7 +398,7 @@ public function testIfNoneMatchHeaderCanBeSetOnInsert()
$headers = $this->adapter->popRequest()->headers;
$found = false;
foreach ($headers as $header => $value) {
- if ($header == 'If-None-Match' && $value == $etag->getFieldValue())
+ if ($header == 'If-None-Match' && $value == $etagOverride)
$found = true;
}
$this->assertTrue($found, 'If-None-Match header not found or incorrect ');
@@ -414,7 +406,6 @@ public function testIfNoneMatchHeaderCanBeSetOnInsert()
public function testIfMatchHeaderCanBeSetOnUpdate()
{
- $this->markTestIncomplete('Problem with Etag and If-Match');
$etagOverride = 'foo';
$etag = Etag::fromString('Etag: ABCD1234');
$this->service->setMajorProtocolVersion(2);
@@ -436,7 +427,6 @@ public function testIfMatchHeaderCanBeSetOnUpdate()
public function testIfNoneMatchHeaderCanBeSetOnUpdate()
{
- $this->markTestIncomplete('Problem with Etag and If-Match');
$etagOverride = 'foo';
$etag = Etag::fromString('Etag: ABCD1234');
$this->service->setMajorProtocolVersion(2);
View
2 tests/Zend/GData/TestAsset/MockHttpClient.php
@@ -30,7 +30,7 @@
*/
class Request
{
- public $methd;
+ public $method;
public $uri;
public $http_ver;
public $headers;
View
2 tests/Zend/Http/Client/CommonHttpTests.php
@@ -346,8 +346,6 @@ public function testHeadersSingle()
foreach ($headers as $key => $val)
$this->assertContains(strtolower("$key: $val"), $body);
-
- $this->assertContains(strtolower($acceptHeader), $body);
}
/**
View
37 tests/Zend/Http/Client/CurlTest.php
@@ -20,6 +20,8 @@
*/
namespace ZendTest\Http\Client;
+
+use Zend\Config\Config;
use Zend\Http\Client\Adapter;
/**
@@ -56,14 +58,25 @@ class CurlTest extends CommonHttpTests
protected function setUp()
{
- $this->markTestIncomplete('cURL implementation incomplete at the moment');
-
if (!extension_loaded('curl')) {
$this->markTestSkipped('cURL is not installed, marking all Http Client Curl Adapter tests skipped.');
}
parent::setUp();
}
+ public function testSimpleRequests()
+ {
+ $this->markTestSkipped('Method PATCH not implemented.');
+ }
+
+ /**
+ * @dataProvider parameterArrayProvider
+ */
+ public function testPatchData($params)
+ {
+ $this->markTestSkipped('Method PATCH not implemented.');
+ }
+
/**
* Off-line common adapter tests
*/
@@ -95,7 +108,7 @@ public function testConfigSetAsArray()
public function testConfigSetAsZendConfig()
{
- $config = new \Zend\Config\Config(array(
+ $config = new Config(array(
'timeout' => 400,
'nested' => array(
'item' => 'value',
@@ -118,7 +131,7 @@ public function testSetConfigInvalidConfig($config)
{
$this->setExpectedException(
'Zend\Http\Client\Adapter\Exception\InvalidArgumentException',
- 'Array or Zend\Config\Config object expected');
+ 'Array or Traversable object expected');
$this->_adapter->setOptions($config);
}
@@ -172,10 +185,6 @@ public function testRedirectWithGetOnly()
*/
public function testRedirectPostToGetWithCurlFollowLocationOptionLeadsToTimeout()
{
- $this->setExpectedException(
- 'Zend\Http\Client\Adapter\Exception\RuntimeException',
- 'Error in cURL request: Operation timed out after 1000 milliseconds with 0 bytes received');
-
$adapter = new Adapter\Curl();
$this->client->setAdapter($adapter);
$adapter->setOptions(array(
@@ -191,6 +200,9 @@ public function testRedirectPostToGetWithCurlFollowLocationOptionLeadsToTimeout(
$this->client->setParameterGet(array ('swallow' => 'african'));
$this->client->setParameterPost(array ('Camelot' => 'A silly place'));
$this->client->setMethod('POST');
+ $this->setExpectedException(
+ 'Zend\Http\Client\Adapter\Exception\RuntimeException',
+ 'Error in cURL request: Operation timed out after 1000 milliseconds with 0 bytes received');
$this->client->send();
}
@@ -239,17 +251,16 @@ public function testPutFileHandleWithHttpClient()
public function testWritingAndNotConnectedWithCurlHandleThrowsException()
{
- $this->setExpectedException('Zend\Http\Client\Adapter\Exception', "Trying to write but we are not connected");
-
$adapter = new Adapter\Curl();
+ $this->setExpectedException('Zend\Http\Client\Adapter\Exception\RuntimeException',
+ 'Trying to write but we are not connected');
$adapter->write("GET", "someUri");
}
public function testSetConfigIsNotArray()
{
- $this->setExpectedException('Zend\Http\Client\Adapter\Exception');
-
$adapter = new Adapter\Curl();
+ $this->setExpectedException('Zend\Http\Client\Adapter\Exception\InvalidArgumentException');
$adapter->setOptions("foo");
}
@@ -300,7 +311,7 @@ public function testGetCurlHandle()
$this->assertTrue(is_resource($adapter->getHandle()));
}
-
+
/**
* @group ZF-9857
*/
View
2 tests/Zend/Http/Client/ProxyAdapterTest.php
@@ -47,8 +47,6 @@ class ProxyAdapterTest extends SocketTest
*/
protected function setUp()
{
- $this->markTestIncomplete('Proxy adapter incomplete at the moment');
-
if (defined('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY') &&
TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY) {
Something went wrong with that request. Please try again.